
Is Haskell the right language for teaching functional programming principles? - ingve
http://profsjt.blogspot.com/2017/10/is-haskell-right-language-for-teaching.html
======
polyfish42
Beginner programmer here – I just want to say that I credit Elm with getting
me hooked on programming. I tried other languages (Ruby, Javascript, even
Elixir) but I never made it past the first project. With Elm, I've made a few
projects and show no sign of stopping. Here's the best I can determine why:

1\. Elm is simple, so I have fewer options to choose from when solving a
problem. This means I learn a few ideas really well.

2\. Even thought Elm is very much about the web (as the article mentioned),
it's awesome to be able to see things in your browser immediately. It's also
helpful to be able to build an application without a backend. You can see your
model in the same file that you see your view, which helps you more easily
think about each part together.

3\. Complier/Type System: Once I finally figured out Union Types, the compiler
is super helpful and friendly.

4\. Elm forces you to handle errors, functions that can fail, and "Nothing",
all things that you have to (a) know about and (b) remember to do in other
languages.

5\. Lack of tutorials, documentation and libraries to rely on means less
"productivity" but it forced me to really learn the language and how things
worked. I had to implement OAuth without a library, read source code to figure
out what a function did, and couldn't google every problem.

I'm too new to know if Elm taught me the most important things a I should know
about programming, or if there are better options out there. I do know that
it's really fun. As a beginner, that might be the most important thing.

~~~
BoiledCabbage
This is so true. Anyone who wants to see the ideas behind Haskell and It's
style of languages succeed should be doing everything they can to support elm.
You can't find and easier, more straightforward introduction to the concepts
and style of programming than it.

Yes purists will complain about the bells and whistles it does have, and
that's exactly the point.

You can learn elm and be productive in it in after a single weekend. And it's
error messages should be _the_ industry standard for language messages in any
language. It's incredible how simple and accurate they are. It will change
your view of what a compiler is capable of.

Not to mention it's not a far leap for people already doing web coding.

~~~
anthonybullard
I would just like to mention that as of 1.5, Elixir has stepped it's game up
on error messaging as well, to get as close it can get to Elm's(which truly
are fantastic) without static typing.

------
norswap
As much as I hate to say this, I think untyped functional programming is the
way to go to teach about the virtues of functional programming.

We do this at my university using the obscure but awesome Oz programming
language (1). But then students (and some professors, truth be told) complain
that it's obscure...

If I had to pick one, I'd say Elixir. It's like Erland with less wonky syntax.
Another option is a pure scheme. But people hate on the parens (yes, it's not
very smart, but people are going to do it anyway).

Pyret (2) is also made for this purpose, but that's sort of the caveat: it's a
teaching language and people don't like that.

(1)
[https://www.info.ucl.ac.be/~pvr/book.html](https://www.info.ucl.ac.be/~pvr/book.html)
(2) [https://www.pyret.org/](https://www.pyret.org/)

~~~
pivo
Too bad about scheme, that's the language I used to learn functional
programming and it seemed to make so much sense in that context.

~~~
submeta
I got in touch with Scheme twenty years ago. Read the specification (R5RS) and
that was the first time programming in Lisp made sense to me. Because the
specification was so short, I could remember every detail after a short time.
Also the syntax was so predictable unlike Common Lisp with its myriad of
operations. Without reading too many books about Scheme I started programming
in it. Learned about tail recursion. About destructive vs non destructive
operations. About functions that always returned values. Then I got in touch
with SICP ("Structure and Interpretation of Computer Programs"). Man, that
book was a revelation.

Scheme was a breathe of fresh air coming from C/Pascal/Java. It was a totally
different way to tell the computer what I wanted to do (although I had similar
thoughts several years earlier programming my HP28s calculator in a Forth like
language, then later when I started using Mathematica).

------
hellofunk
Haskell is really the intersection of functional programming and static typing
at the highest level, and these are 2 very different things, and it will be
very easy to get lost in the typing aspect for fear of not grasping the
functional aspect.

If your goal is to teach just functional programming, then Haskell may be too
much since the language is about a lot more than just functional programming.

Scheme or a light lisp (including Clojure) is often the way FP is initially
taught, since you can focus directly on the functional aspects and leave the
complexities of static typing out of it. This was the tradition at MIT for a
long time (maybe still is).

~~~
jdeisenberg
Hackett ([https://github.com/lexi-lambda/hackett](https://github.com/lexi-
lambda/hackett)) seems like an interesting project in this regard.

------
CJefferson
My feeling is Haskell is a bad teaching language for the same reason C++ is --
there is too much "this is some crazy stuff you have to learn about the
language" early on.

One reason I have learned to love teaching Java over C++ is that the language-
based bugs tend to be "shallow", at least in the first few weeks. The error
messages tend to be easy to interpret, and when programs crash it is easy to
understand why (how to fix it might be hard of course!)

For later year students, it's fine to expect them to learn the weirdnesses of
Haskell and C++, but not for a student on day one.

~~~
jorvi
It's all in the approach. I've noticed most universities these days either get
students started on Python or C. I believe the idea behind starting with
Python is that most beginning students will hit the ground running, whereas
the idea for C is that you get thrown in the deep end but will have a deeper
understanding (and perhaps foundation) going forward. Which approach is better
I dare not say..

~~~
msla
C is good for teaching a simplified machine model, one with a distinction
between stack and heap, pointers, and a purely sequential execution model.
This is enhanced if you use it to program an Arduino or similar trivial
hardware, collapsing the division between hardware and software to one piece
of hardware (the single-board computer) and one piece of software (the code
the student wrote) and nothing else.

C, in short, gives a good way to control actual hardware without having to
introduce students to the complexities of actual hardware.

Python is good for teaching algorithms and OO design, precisely because it
allows students to focus on the algorithm while not having to slow down the
course with memory management.

In both cases, the idea is clear: Only teach one hard thing at a time, and
then build.

------
adjkant
Racket / HtDP is the best way to teach functional programming to beginners.

[http://www.ccs.neu.edu/home/matthias/Thoughts/Growing_a_Prog...](http://www.ccs.neu.edu/home/matthias/Thoughts/Growing_a_Programmer.html)

Haskell obviously has its place, but it is much better used when looking at
something like PL Theory at a 3000-400 level.

~~~
cglouch
Definitely agreed. I was introduced to functional programming via Pyret, which
is similar to Racket and draws from HtDP in terms of pedagogy. It's a much
gentler introduction than being thrown to the wolves with Haskell or OCaml.
I'm sure one could learn FP effectively with those languages too, but if
you're still trying to wrap your head around the functional paradigm you don't
really want to have to stumble across words like "endofunctor" while reading
the documentation. I even have a good math background but I would have found
that confusing at the time.

[https://www.pyret.org/](https://www.pyret.org/)

~~~
adjkant
Glad to see people are enjoying Pyret! If you don't like the parenthesis in
Racket, this is the path for you.

------
MBCook
I wouldn’t think so. Maybe Clojure?

I kind of like Haskell but I’ve been turned off by the way some of the
development is done.

There is, for all intents and purposes, only GHC. Yet everyone uses it by
tuning on all sorts of special options to make it more usable. Why are they
options? To remain ‘compatible’ with the ‘other Haskell compilers’ that
basically no one seems to use.

It’s like if JS all defaulted to 1.0 and you had to pile on options to use any
features after 1998.

It just makes things much more confusing and odd than necessary. To support
something it seems like no one uses.

It will also be easier once the whole applicable/monad thing is done.

~~~
slowmovintarget
Clojure's focus, after simplicity, is functional programming.

Haskell's focus is as an experimental vehicle for type system theory. If you
want to teach type system and category theory, use Haskell.

Functional programming does not require Hindley-Milner type inference, and
that happens to be one of the larger cognitive hurdles in Haskell. Algorithm W
is a layer on top of the Lambda Calculus, not something essential for
understanding it.

+1 for using Clojure to teach Lambda Calculus^h^h^h functional programming.

~~~
platz
Just because there are _some_ folks that use Haskell for for experimental
studies, doesn't mean that Haskell is _not_ a great language for line-of-
business programming.

I can't say it better than Gabriel Gonzalez:

"Haskell is unbelievably awesome for maintaining large projects. There's
nothing that I can say that will fully convey how nice it is to modify
existing Haskell code. You can only appreciate this through experience.

When I say that Haskell is easy to maintain, I mean that you can easily
approach a large Haskell code base written by somebody else and make sweeping
architectural changes to the project without breaking the code."

------
oggyhead
Having learnt Haskell as my first programming language, sure it has a high
learning curve but it pays off in so many ways. It is without doubt the most
beautiful language ever conceived. Without doubt it is the right language to
unlearn imperative bs and the right language to learn functional programming
principles. Even against the likes the of lispy langs and other ml flava,
Haskell reigns supreme with it's purity

~~~
gnaritas
The question is about learning functional programming, Haskell forces you to
learn much more than that to use it. Functional programming should be taught
in something like Scheme, which lets you focus on the functional without being
forced to also deal with a crazy Hindley-Milner type system that has nothing
to do with functional programming. Haskell is not the right language to learn
functional programming in, it's not the right language to learn anything in,
beginners should start in easier languages.

> It is without doubt the most beautiful language ever conceived.

Only if you're a masochist.

~~~
oggyhead
Quite honestly, I feel if you think Haskell's beauty is somehow in any way
associated with masochist mindset , you most likely think Maths is associated
with a masochist mindset and (assuming math defines reality) the true nature
reality is only viewable to those with a masochist mind. Then friend, I truly
am a masochist

~~~
gnaritas
Yep :). I don't agree math defines reality however; it can describe reality,
it doesn't define it.

------
meebob
I think there is also an emotional/social dimension to choosing a beginner's
language that is important to take into account.

Imagine (putting Haskell's static typing aside), the difference in feeling
between learning the basics of FP (say higher order functions, streams, all
the different ways of dispatching function calls, etc.) in Haskell, vs OCaml,
vs Clojure, vs scheme, vs javascript. Poking around on the internet, the
beginner is going to get really different aesthetic vibes from each of these
languages.

To shamelessly generalize: \- Haskell/OCaml feels cerebral, academic,
Mathematical, maybe even elitist \- Clojure/scheme has that dark-terminal
screen, classic 80s vibe- to me it feels nostalgic and quirky. \- Javascript
is, of course, javascript- it's bright, active, and, most of all, popular

All of these will bore/intimidate/comfort/excite different student
demographics in different ways, completely independently of the programming
concepts that you're teaching. So I think it's important to keep in mind the
aesthetic preferences of the students you're trying to catch.

------
sddfd
What do you think about Standard ML as a language for teaching?

I like it because the syntax is clean, it is functional and higher-order, but
also has an explicit concept of references (i.e. mutable memory) and using
functions with side effects (i.e. printing) is no trouble at all.

~~~
mahmud
I have been programming for over 20 years, most of it in FP land. ML is
tractable, a beautiful prism through which one can peek at Computer Science as
a subject, but it has a frustrating lack of _practical_ tooling and beginner-
friendly community. For anything outside basic I/O, you will need to dust off
compiler-specific extensions, most of them last used on "Un*x Workstations".

Just look at the Basis library. Safe to say it's nowhere near Racket, Scala,
Clojure, Kotlin, ...

[http://sml-family.org/Basis/manpages.html](http://sml-
family.org/Basis/manpages.html)

~~~
tytytytytytytyt
I never understood why a lack of tooling would be a serious problem for a
language used for teaching FP.

~~~
yawaramin
It's a tough sell if the language has no hope of industry adoption. Also tough
to use a language, especially one with type inference, without editor support.

~~~
tytytytytytytyt
Most people in my SML class seemed to have no problem with either of those.

~~~
yawaramin
Maybe some classes are just that good. A lot aren't, I'm guessing, and you
would want to at least take away something you could use in the real world
from them.

------
hackermailman
Robert Harper has written a few posts on his personal blog why they use SML to
teach functional programming, why they teach it to freshmen, why they don't
use Haskell ect [https://existentialtype.wordpress.com/2011/03/21/the-dog-
tha...](https://existentialtype.wordpress.com/2011/03/21/the-dog-that-didnt-
bark/)

 _" Finally, this article explains why Haskell is not suitable for my
purposes: the principle of induction is never valid for a Haskell program! The
problem is that Haskell is a lazy language, rather than a language with
laziness. It forces on you the existence of “undefined” values of every type,
invalidating the bedrock principle of proof by induction. Put in other terms
suggested to me by John Launchbury, Haskell has a paucity of types, lacking
even the bog standard type of natural numbers."_

------
erik14th
I think Haskell is a beautiful language, but it's community seems too elitist
and pedantic, which from my perspective makes people value sophistication and
"elegance" over readability and ease of comprehension. I'd recommend Elixir,
it's code is beautifully readable, it's pragmatically functional since it's
based on Erlang, I'm not refuting Haskell usefulness in the real world, I'm
just pointing out it's functional nature is academic, while Erlang's
functional essence is pretty much a colateral effect of the problems it was
aimed to solve. edit: Thinking again, even from the academic perspective, I'd
still go for something like Racket, in my sense of aesthetic there's no
competition to the beautiful simplicity of lisp.

~~~
neilparikh
Could you clarify what you mean by elitist/pedantic? I've found the Haskell
community to be fairly friendly, and very open to beginners (including when
they ask basic questions).

I've mostly been on /r/haskell and Quora, and watched talks by Haskellers
though, so maybe the community is different on other platforms.

~~~
Sophistifunk
I'd say this thread is a perfect microcosm of it. In JavaScript, the general
attitude is "you're right, this thing you're complaining about _is_ kinda
stupid, here's this tool to make it go away" versus "no, you're wrong, Haskell
is great, STFU"

~~~
neilparikh
I don't think that's really true in the Haskell community. I've seen lots of
self-criticism of Haskell on /r/haskell. Even SPJ himself is willing to admit
that Haskell has design mistakes.

Some things Haskellers readily admit as issues with Haskell:

\- the String type

\- records

\- laziness (more contentious, but many people agree that this might not have
been the right choice)

\- error messages

\- the prelude

Essentially, my experience has been that Haskellers are willing to accept that
Haskell is not perfect.

~~~
tome
Indeed, the Haskell community is very self critical, much to its credit.

[https://www.reddit.com/r/haskell/comments/3b498l/if_you_coul...](https://www.reddit.com/r/haskell/comments/3b498l/if_you_could_change_one_thing_about_haskell_what/)

------
lisardo
I learned FP using Racket. It was a good experience, but the parenthesis were
really annoying. It makes you feel stupid.

I believe Elm would be better choice. It would allow to get a visual result
easily (html), there is a clear convention about code formatting and the
compiler errors are really friendly.

------
alaties
I think Haskell is very akin to C++ in terms of learning curve.

There are a ton of concepts you have to learn up front to even get started.
The compiler is generally unhelpful if you've never dealt with it before.
There are a lot of approaches to solving a problem and the language does not
make it clear which approach is preferred when. Unless you're a masochist,
these qualities can be quite off putting.

I think a language like OCaml is a good entry point into functional
programming. The compiler errors are really useful. The language pushes you
towards a sane functional approach. The learning curve is pretty smooth, too.

My alma mater seems to agree and FP with OCaml in the upper level CS intro
course
([https://www.seas.upenn.edu/~cis120/current/index.shtml](https://www.seas.upenn.edu/~cis120/current/index.shtml)).

------
justinhj
My path to functional programming started with Paul Graham’s lisp essays and
books and then SICP and Scheme. I visited the world of Haskell but only half
heartedly as I was much happier in a dynamically typed world for my hobby
projects. As a daytime C++ coder I found types an annoyance; so much time
wasted getting something to compile. Later I came to discover types again with
Scala and now I’m fully sold. I will revisit Haskell again some day but most
likely will learn Elm first. Elm is a much friendlier ML style language and
much more explicit about things like monads. Moving from Elm to Haskell is
much easier since the programmer will have “aha” moments mapping what they did
explicitly in Elm to what you can do more generically with type classes in
Haskell

~~~
cryptonector
I'm lucky enough to own copies of On Lisp and ANSI Common Lisp. These books
are a pure pleasure to read -- a lot like reading a novel.

~~~
flavio81
May the warm light of Lisp enlightenment shine on you -- CL blew my mind!!

~~~
cryptonector
I strongly recommend these two books. They are amazing!

------
mjhoy
I love Purescript, but I think in some ways it is even more arcane than
Haskell for a beginner.

e.g.,

    
    
        > :t (+)
        forall a. Semiring a => a -> a -> a
        
        > :t (&&)
        forall a. HeytingAlgebra a => a -> a -> a

~~~
kccqzy
But it requires a different kind of skill altogether. A semiring is a concept
in abstract algebra that’s quite independent from general functional
programming.

~~~
mjhoy
That's kind of my point. Usually when you're just learning "general functional
programming", you're thinking about, say, (+) as a function that takes two
numbers, and returns a number, because you're at the stage of figuring out how
something like

    
    
        fold (+) 0 [1,2,3]
    

works. Introducing "Semiring" as a concept at the same time can be a bit much
for a beginner!

I do think it's a useful concept, and that Purescript is an excellent,
intermediate-level FP language.

------
crimsonalucard
I do believe that Haskell is the wrong language to learn functional
programming principles. Right off of the bat Haskell forces learners to use
monads for IO. Monads are an advanced concept; too advanced for beginners. If
learners end up do kind of getting the IO monad, a big number of them actually
end up not being able to understand why it's good or even understanding what a
monad is completely... and see it as a pointless overcomplicated abstraction.
I knew a person who learned Haskell then moved on to javascript due to the
wall he hit while trying to understand monads. I've looked at his javascript
code and his idea of functional programming is just littering his imperative
javascript code with maps, reduces and filters.

Thanks to redux, a lot of people are getting a broken view of what functional
programming really is via javascript. If you think you've learned functional
programming via react/redux and javascript... chances are you haven't really
understood it yet. Ask yourself, why is functional programming called
functional programming and not called immutable programming? If you don't know
the answer... you haven't really grokked functional programming yet.

The right language? Racket maybe?

~~~
yawaramin
I disagree that you have to learn monads for IO. I know some tutorials mention
monads right off the bat while teaching IO but that is not a recommended
teaching approach.

For IO what you would need to learn is that all IO actions are values of the
`IO` type and they can be sequenced together for guaranteed ordering using the
`do` notation. That's it. No monads. We can introduce monads after we show
using the same `do` notation for lists, `Maybe`s, and `IO`.

~~~
crimsonalucard
>For IO what you would need to learn is that all IO actions are values of the
`IO` type and they can be sequenced together for guaranteed ordering using the
`do` notation. That's it. No monads. We can introduce monads after we show
using the same `do` notation for lists, `Maybe`s, and `IO`.

This is an awkward teaching approach. Forcing learners to use advanced
concepts without fully understanding them. Why can't haskell just have a print
function that returns a void? How come when I use haskell with input it starts
polluting the input with this IO thing? This all seems stupid initially and it
takes a lot of learning to understand why things are done this way.... I mean
that person I know thinks javascript is better than haskell because
console.log("hello") is ten times more straightforward.

~~~
yawaramin
I disagree that it's forcing learners to use advanced concepts. It's giving
them syntax sugar and a fairly clear introductory explanation (IO is done only
with the `IO` type for safety reasons) and giving them all the capabilities of
IO in other languages straight from day one.

Forgetting about types for a second, can you really say that `putStrLn
"hello"` is harder to understand than `console.log("hello")`? Trust me when I
say this, plenty of people have taught Haskell to kids and the result has
always been that they pick it up easily. Programmers from other backgrounds
worry away too much of their mental capacity thinking about monads. Stop
worrying about it and just hack away.

~~~
crimsonalucard
Understanding a pattern is different from copying a pattern. Our disagreement
lies not with kids copying a pattern but with people fully comprehending the
philosophy and true nature of the monad abstraction. This is not easy for a
beginner. Allow me to elucidate:

Here is a an example of a trivial operation in imperative programming that
becomes a bit more complicated in Haskell: Create a function that prints
everything in an array:

naive implementation in haskell (won't work):

    
    
      printElements arrayOfStrings= map putStrLn arrayOfStrings
      main = printElements ["Hello", "World"]
    

True implementation:

    
    
      printElements [] = return ()
      printElements x:xs = (putStrLn x) >> (printElements xs)
      main = printElements ["Hello", "World"]
    

The second implementation requires understanding of types and the IO monad
while the first implementation is a naive and broken implementation that most
people turn to when learning Haskell.

It is not trivial to explain to a person why it must be done the second way...
All of this and all we were doing was printing something to the console! It's
too much! Monads aren't even a required part of functional programming.
Haskell is not a great language to learn about functional programming.

~~~
tome
Actually the "true" implementation is

    
    
        printElements arrayOfStrings = traverse putStrLn arrayOfStrings
        main = printElements ["Hello", "World"]
    

but the difference between map and traverse is sufficient for your point to
still hold water.

~~~
yawaramin
I think we would actually use `mapM_` rather than `traverse`.

~~~
tome
Or rather `traverse_`. (I still don't know why `traverse` is not renamed
`mapA`.)

~~~
yawaramin
Interesting, I don't see `traverse_` in Prelude in 8.0.2 that I have on my
machine.

~~~
tome
It's not in Prelude, it's in Data.Foldable.

------
shados
Absolutely not. You need a gateway drug before Haskell becomes interesting.

It's one of those things where you should not use a solution to a problem
until you understand what the problem IS. Otherwise you'll feel like things
are complicated for no reason.

ML, Elm, Elixir, Closure or even (yes, really) JavaScript are much better
places to start.

~~~
hellofunk
I think you mean Clojure, not Closure. The latter is a library by Google.

~~~
shados
Yes, Clojure :) I wasn't even thinking the library, but the programming
concept when I typoed it. Whoops!

------
hbbio
I have taught FP to more than one thousand students over 5 years. For all of
them, the language was OCaml (at several universities, in Paris).

At the time and still today, I think that OCaml is a very good language to
learn FP. Students that learn FP before any other programming language get it
quickly, and others can compare and write both the imperative and the
functional form of a given program. But as a whole, the installation is easy
and uniform (which matters a lot when teaching) and the standard library
sufficient for everything, as you never want to have a lot of dependencies for
the same reason.

Of course, OCaml has its drawbacks: A weird syntax, terrible tooling... but
you don't really see that when learning programming concepts. The only
students which complained were the ones which already spent a lot of time
programming before class _and_ trollers at the same time.

~~~
yawaramin
For dismissing syntax complaints, have you looked at ReasonML?

------
galaxyLogic
Haskell syntax is terse but not simple. Not good for teaching Functional
Programming PRINCIPLES. See:
[https://www.haskell.org/onlinereport/haskell2010/haskellch10...](https://www.haskell.org/onlinereport/haskell2010/haskellch10.html)
.

How about using Lisp to teach functional programming? Lisp syntax is small,
simple. You don't need to teach so much Lisp as teach with Lisp.

------
crusso
Given your constraints, I'd say that Elm is an excellent choice. It's
simplistic enough to be approachable, the easy web integration is a feature
(not a drawback as you mentioned), and people are doing "real work" in Elm so
they will be able to use it for years moving forward.

------
bpyne
This question leaves me with more questions. The post looks at a few
alternatives without giving context.

1\. How does the course fit the overall curriculum? 2\. What is the experience
and maturity of the people taking the course? 3\. How strong are the teaching
skills of the instructor?

The density of functional features taught in a certain time period matters. A
drastic change in mindset simply takes time that, I would say, is greater than
a standard semester. A single semester is fine if FP is going to be
reinforced, thereafter, in other courses.

Also, starting students with FP instead of imperative or OO means less to
break down and relearn.

I've read numerous debates that try to define functional programming. I don't
want to start another one because they're tedious. My experience is that
functional programming is a change in mindset in how to solve a problem and
organize code. The instructor's ability to teach matters. The time given to
learn matters. Reinforcing the concepts throughout a curriculum matters.

For each point I make above, you could make a valid case for a different FP
language/ecosystem. As much as I like Haskell, it's not a "one size fits all".

------
nicolashahn
I learned Haskell in a course called "Comparative Programming Languages" by
Cormac Flannigan
([https://users.soe.ucsc.edu/~cormac/](https://users.soe.ucsc.edu/~cormac/))
my last year in college, so I had done a lot of procedural, object oriented
programming by then, but no real emphasis on functional and especially not
purely functional.

It was probably my favorite course I took in college, owing a lot to his
outstanding teaching style. It awoke an interest in programming languages and
a strange fetish for the beauty of them. I was probably the odd one out, few
other students enjoyed it as much as I did. I became a slightly rabid Haskell
promoter for a little while. I realize it's not great to build most things in
but I think everyone should have the same experience I did with it (after
learning some basic programming and gaining a working knowledge of at least
one "easy" language like Java or Python, but before you've spent too much time
with them and have solidified your opinions).

------
te_chris
In my personal experience: No. I tried Haskell and Scala multiple times but
never worked. Once I got to elixir everything just sunk in and felt easy. YMMV

------
chasedehan
Buy this: [http://haskellbook.com/](http://haskellbook.com/)

I tried LYAH and some other sources a few times, but was really turned off by
those approaches. It wasn't until i found HaskellBook that I really started
liking it.

I think a lot of it depends on the background of the person learning. I came
from a strong math/stats background before I learned to code and so much of it
clicked a lot better than other imperative languages.

------
amatecha
I'm currently learning Haskell from "Haskell Programming From First
Principles"[1] and enjoying it so far (even attending a local weekly study
group). I'm absolutely learning functional programming principles and then
some. Pretty effective thus far, and I find it extremely accessible.

[1] [http://haskellbook.com/](http://haskellbook.com/)

------
ajuc
I've mostly learned functional programming with SML at university, and then I
learned Clojure with no problems, and after that I still had problems with
learning Haskell.

So I'd say - no.

I especially had problems with searching for varios operators and what exactly
they do. Also (despite having some experience with SML) - currying makes
function definitions hard to read.

~~~
yorwba
I have never seen an operator that I couldn't find with Hoogle.

E.g. for (&&&):
[https://www.haskell.org/hoogle/?hoogle=%26%26%26](https://www.haskell.org/hoogle/?hoogle=%26%26%26)

You can also search by type:
[https://www.haskell.org/hoogle/?hoogle=%3A%3A+String+-%3E+IO...](https://www.haskell.org/hoogle/?hoogle=%3A%3A+String+-%3E+IO+%28%29)

------
js8
It worked for me, but I guess (also based on comments here) it depends on
personality. I like to learn (work things out) from theory and I generally
prefer to learn elegant languages that introduced some concept rather than a
watered down version of that concept as it was adopted in more pragmatic
languages. Some other people might prefer to be more practical and understand
the theory later, and so prefer languages that are more pragmatic before they
accept a new paradigm.

Haskell, due to its annoying insistence on pure functions, made functional
programming click for me. I have seen functional style in impure languages
before (Common Lisp) but I didn't have the discipline to really code that way
- I only saw the downsides. Haskell forced that discipline on me, so I could
also see the upsides. One significant upside is that one is forced to make
functions really small, which leads to more readable and composable code.

------
greencore
Haskell itself is difficult to understand unless you give someone to read
"Learn you a Haskell for great good". I was giving this book to my junior
developers to read for understanding such principles like recursion, list
manipulation functions like map, filter, reduce etc. and it worked pretty
well.

------
GarvielLoken
SICP in Scheme is the only true answer. You are all heretics.

------
joelhaasnoot
I actually enjoy the benefits of my course in Clean at university (
[http://clean.cs.ru.nl/Clean](http://clean.cs.ru.nl/Clean) => "Clean is a
general purpose, state-of-the-art, pure and lazy functional programming
language"). While challenging, it taught me all the functional principles.
Many of the language features and principles can be applied and useful for
understanding Python, Scala, Kotlin, etc.

Applying it to something that wasn't just plain 'ol boring was slightly hard,
but creating soccer team logic as the final project with a pre-written GUI
module was lots of fun. Before that I never thought exams that required
writing actual code were a good idea, but this one pulled it off well.

------
opaqe
Why not ML? Our programming languages course had a unit in ML and the transfer
to Haskell after that was not trivial but still a smooth learning curve -- I
could read not just getting-start or for-beginner guides.

------
davesque
One might consider using a functional language which isn't lazy. Haskell's
laziness makes its behavior harder to understand and is not necessary to
illustrate the core concepts of FP.

------
sriku
Not entirely on topic, but related, I have an evolving attempt at introducing
programming language concepts by building a forth-like language in JavaScript
-
[https://github.com/srikumarks/nospoon](https://github.com/srikumarks/nospoon)

It is written in a stream-of-thought literate style. Feedback welcome as
issues.

------
pacala
Use a good _library_ of persistent immutable data structures. In any language
your audience is already familiar with.

~~~
adrianN
Functional programming is not just about using immutable data structures.

------
ShareDVI
I had an FP course on F#, really liked it.

------
Chiba-City
Haskell Type Classes are brilliant. But I would recommend a strict evaluation
language like ML (and modules with signatures) for Semester #1 and lazy
Haskell for Semester #2. Anyone could cover a ton of useful contextual
material taking just a little more time.

------
kevinSuttle
I'm in the boat of learning FP right now. What would really help me, and folks
in the same process, is for people to suggest languages that _would_ be
better, and why, instead of doing the stereotypically HN commenter thing that
I'm already seeing.

~~~
yawaramin
I always recommend [https://www.coursera.org/learn/programming-
languages](https://www.coursera.org/learn/programming-languages) for learning
FP, the professor has fantastic explanatory videos that are really clear and
concise. You'll get the most out of it from doing the exercises, but you can
still take away a lot from just watching the videos.

~~~
kevinSuttle
Thank you. I'll check that out.

------
k__
Probably not, because it's lazily evaluated and almost no other language is.

------
jgtrosh
> Full disclosure: at Kent, after teaching Haskell for many years, we
> currently a compulsory second year course on “functional and concurrent
> programming”

s/currently/currently dispense/

------
gurelkaynak
We were thought functional programming with Dr. Scheme and Miranda. I think
they were ok. Never had any problems with them. Have no idea about haskell.

~~~
dualogy
> Have no idea about haskell

Born as a non-proprietary Miranda alternative, but instructors would have to
be careful to side-step various modern quirks across the libs ("SQL as a free-
monadic-profunctor-optics" and such broohaha) for a similar teaching
experience.

------
pklausler
Is there any other language with purity, laziness, and static types that could
possibly be put forward as an alternative to Haskell?

------
bitwize
Functional programmers practice a form of no-true-Scotsmanism wherein type and
category theory are an intrinsic part of "true" functional programming. So
unless you are working in something with a type system _at least_ as
expressive as Haskell's, you are -- arguably -- not doing _true_ functional
programming. (Sorry, Schemers.)

------
latj
I knew the answer after just reading "Is Haskell the right language..."

------
galvs
Go SJT! He taught me haskell back in 2003 - rotating ascii horses

------
sitkack
I think Python is a wonderful language to teach functional programming since
it is so accessible for many definitions. One has to go a little off the rails
to get all the functional features, but it is possible.

~~~
Myrmornis
I also suspect this makes sense for an introductory FP class (FP, not static
typing). The students have already already met the language, and they can
compare functional and imperative styles of solutions to the same problem. I
think I’d go with python, and then have one or two lectures near the end
showing a language dedicated to FP / static typing.

~~~
sitkack
Yeah, and by using a widely available language, they can actually use these
techniques in the field.

------
megaman22
No. It's a great way to turn people off from the whole idea.

I suffered through a course in Haskell and functional programming in college,
and the course material was so up its own butt about monads and type classes
and algebraic data types and such, that I essentially wrote the whole thing
off as academic flubbery. It didn't help that whatever version of GHC we had
then gave off error messages more cryptic than C++ template metaprogramming,
and it was such a cluster to have to bounce into the IO monad to just to do
some intermediate printf debugging.

It wasn't until years later and exposure to .NET LINQ that it started to click
and the motivations for why you would want to use functional programming
became apparent.

~~~
bad_user
While I agree that many courses on Haskell are no good ...

>> " _up its own butt about monads and type classes and algebraic data types_
"

Well, those are some of the best things about doing functional programming in
languages that can afford them.

>> " _I essentially wrote the whole thing off as academic flubbery_ "

And maybe it was your attitude to the whole thing.

>> " _It wasn 't until years later and exposure to .NET LINQ that it started
to click..._"

So seriously, can't you find anything else that changed " _years later_ "?
Haven't _you_ changed? Aren't we talking about years of accumulated
experience?

Also, .NET LINQ might be a cool example of what you can do with FP, there are
elements of FP in it, certainly that's a monadic interface that makes it tick.
But filtering an IEnumerable or an IQueryable is as interesting as executing
an SQL query.

What have you learned about FP from executing SQL queries? Probably nothing.

Just saying.

~~~
NightMKoder
Functional languages and strongly typed languages are not the same set. Most
functional languages focus on typing (e.g. Haskell, Scala), but there are
functional languages that do not (e.g. Clojure, Common LISP). You can easily
do functional programming in clojure without using any monad concepts directly
(though obviously it’s easy to say “that’s just a monad” in a lot of cases).

IMO the biggest win from functional programming is referential transparency.
Automated verification (i.e. type checking) can definitely be useful on larger
projects with bigger teams since it’s self documenting. That’s just my
personal take on it though - there’s plenty for everyone to like.

~~~
bad_user
You're mentioning Clojure.

Clojure has _protocols_ which are probably inspired by type classes. Just like
Clojure's protocols, type classes are a mechanism for ad hoc polymorphism that
allows decoupling between data and the functions operating on that data.

Clojure indeed doesn't have monads, but this has to do with Clojure's culture
(like all LISPs) of using macros for describing APIs for composing stuff. But
those APIs aren't unified and some of the DSLs I've seen do not have a
theoretical foundation, which really means they aren't reusable and some of
them are flawed.

Due to its evolution and backwards compatibility concerns, some of its design
shows its age as well. You can't make operations like "map" work on your own
data types because it doesn't have a protocol defined for it.

Don't get me wrong, I actually like Clojure, but that the community is not
using types like monads to drive their design is a flaw.

~~~
slowmovintarget
What do you mean by "doesn't have monads?" You just write monads in Clojure.
They are only a structural formalism. [1]

If you meant doesn't have the Maybe monad built in... why would you want that
tangled up in your data? [2]

    
    
      [1] https://github.com/khinsen/monads-in-clojure/blob/master/PART1.md
    
      [2] https://youtu.be/2V1FtfBDsLU?t=2381

------
gnaritas
No, teach in Scheme; functional programming has shit to do with advanced
static type systems.

------
abritinthebay
No. The best language is likely the one you know best. Be that Ruby, JS, Rust,
or C++.

That way you can concentrate learning the _principles_ and you’ll immediately
know how to apply them.

The basic principles aren’t hard anyhow - you can learn them completely in a
day. The hard part is _applying_ them and understanding the trade offs.

------
walterstucco
No

------
lonk
No. You need to understand monads before learning FP and you need to learn FP
for understanding monads. This is chicken/egg problem. Functional programming
is overrated.

~~~
dragonwriter
> You need to understand monads before learning FP

No, you don't. You don't even need to understand them before learning Haskell,
much less before learning FP using a language which doesn't use monads as
pervasively as Haskell does.

You obviously need to learn at least something about monads _as_ you learn
Haskell, but understanding them is not a prerequisite.

