
Some Notes on Haskell Pedagogy - sjsyrek
https://medium.com/@sjsyrek/some-notes-on-haskell-pedagogy-de43281b1a5c
======
kmicklas
Some good thoughts in here. However I feel like when I learned Haskell (which
was actually my first serious foray into programming) the hard parts were not
this high level functional language philosophy stuff, but rather not knowing
how to appropriately use the tooling. It took me years to finally write cabal
files, QuickCheck tests, Traversable instances, etc. In that regard, this
guide has been immensely useful:

[http://dev.stephendiehl.com/hask/](http://dev.stephendiehl.com/hask/)

~~~
brudgers
I've had very similar experiences. I took a Scala course on Coursera back in
2014 and at the end I realized I couldn't really write a Scala program because
the course had provided all SBT files for everything...and because they
enabled all sorts of functionality related to autograding, they were
impenetrably complex in addition to the necessary complexity of a build tool
(which requires a willingness to read a technical manual that assumes I high
level of experience and sophistication).

A lot of the difficulty is that it is relatively easy for a two pizza team to
have enough experience and knowledge to collectively figure out how to get all
the moving parts moving more or less in the right direction at more or less
the right time. For an individual, it's always going to take years to achieve
the equivalent knowledge of a team after six months.

------
plandis
functor, sum type, recursively defined.

This teaching opportunity is already lost. Who are you teaching to? Someone
new to programming is going to be lost by the first example.

~~~
runeks
I agree. From the article:

> The | operator indicates that this is a sum type [..]

This doesn't explain what's going on; it references terminology used only by
people who already know what's going on.

A pedagogical explanation would say: the | operator means "or", in that you
can use multiple different constructors (separated by |) to construct the type
in question (whose name is to the left of the '=' operator). For example:

    
    
        data Bool = True | False
    

means that you can construct a value of type _Bool_ using one of the
constructors _True_ or _False_.

~~~
danieldk
But the constructor approach does not explain what makes a sum type a sum.

If the readers already have some background in a programming language, you
could also start with e.g. a struct from an imperative language:

    
    
      struct Foo {
        X x;
        Y y;
      }
    

This is a so-called product type, because the number of possible values of
_Foo_ is the number of values of type X _times_ the number of values of type
_Y_. So if _X = {Red, Green, Blue}_ and Y = _{Light, Dark}_ , then this
product type has _3 x 2 = 6_ different values:

    
    
      Foo {Red, Light}
      Foo {Green, Light}
      Foo {Blue, Light}
      Foo {Red, Dark}
      Foo {Green, Dark}
      Foo {Blue, Dark}
    

What if instead, we wanted to have the sum of the possible values of X and Y?
In other words, where we'd have to choose between a value from X or from Y?

    
    
      Foo {Red}
      Foo {Green}
      Foo {Blue}
      Foo {Light}
      Foo {Dark}
    

That's a sum type: it is a type where you can pick a value from X _or_ Y,
giving a total of _3 + 2 = 5_ possible values.

Then give a motivating example where one would need such a type (e.g. trees
nodes) and introduce proper notation.

~~~
hcs
I agree with your approach, one suggestion: If you're using struct to
introduce product, does it make sense to use union to explain sum? Although
maybe that's too complicated given the need to tag it?

------
stewbrew
"Pedagogy" is the art/science to guide kids, literally speaking. First, I
wasn't sure if he didn't actually mean "didactics" but then he talked about
"students" so he probably just talks about "kids" of computer science.

Why are all thoughts about how to teach/promote Haskell centered on the
language itself as if it were only an academic tool? If you want students to
get excited about Haskell, don't make it look like an academic tool that's
only useful as a didactic device in university classes on functional
programming.

~~~
twblalock
> "Pedagogy" is the art/science to guide kids, literally speaking. First, I
> wasn't sure if he didn't actually mean "didactics" but then he talked about
> "students" so he probably just talks about "kids" of computer science.

 _Literally_ speaking, you may be right, but who cares? "Pedagogy" means
"teaching" to anyone who is seriously engaged with the topic of conversation
here. Etymology is not meaning. Defining words by their etymology alone
ignores history, culture, and the context of modern word use.

~~~
stewbrew
It matters when you're teaching professionally.

