
Learn Haskell Fast and Hard - psibi
http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/
======
ludicast
This is a tremendous resource, but may I suggest you rather point here:
[https://www.fpcomplete.com/school/haskell-fast-
hard](https://www.fpcomplete.com/school/haskell-fast-hard).

It's the same course/series, but with interactivity, so Haskell can
coded/evaluated from the browser. In fact, one "dir" up, you will find a bunch
of similar tutorials here :
[https://www.fpcomplete.com/school](https://www.fpcomplete.com/school).

~~~
cies
I was going to say the same.. To me the Fast-and-Hard introduction made most
sense off all intros I tried (pretty much every one I could find online).

Thumbs-up to FP Complete for integrating it with their tutorial suite!

~~~
deSouza
Regarding the site with the turotial suite: I am not a big fan of harvesting
community knowledge, input and ideas and then go commercial

On a second note, how many will use a platform like fpc's, where an external
entity has immediate access to your code, for serious projects ?

~~~
doorhammer
I'm a big conflicted about that as well.

I think I'm ok with it as long as they have permission/cooperation from the
author (a cursory glance looks like they do; could be wrong), especially since
the introduction of inline code evaluation makes it so much easier to get
into. I know the content probably would have gone into my bottomless "to read
later" bookmarks folder if I couldn't knock some stuff out right then and
there.

Thinking about it, I guess that's just a licensing issue. Give the author the
tools they need to decide how their work can and can't be used.

~~~
aninhumer
School of Haskell is actually a website where people can create their own
tutorials, so most likely the author added it themselves. (EDIT: I just
checked, they were created by user Yann Esposito, which most likely belongs to
the author.)

Furthermore, while FPComplete are commercial, I don't believe they're
monetising SoH in any way, other than its being good marketing for the company
and Haskell in general.

~~~
doorhammer
I thought it might be something along those lines. Just didn't have much time
to look around.

I would say, though, that it should be (and really is) up to the author where
their work can or can't be displayed.

I think it would be good for the community either way, but if an author
doesn't want their work in any way tied to a commercial interest, then it's
their right to apply licensing in such a way to ensure that, and for others to
respect that (though I'm not saying you're implying otherwise; just
clarifying).

The monetization here would be brand exposure and site traffic to the
domain/website, using the works of others (which I'm not inherently against).

------
ssivark
I tried dipping my hands into Haskell over the summer. I fell in love with two
resources:

1\. Yann Esposito's Haskell Fast and Hard (on FPcomplete --
[https://www.fpcomplete.com/user/yogsototh/haskell-fast-
hard](https://www.fpcomplete.com/user/yogsototh/haskell-fast-hard))

2\. Learn you a Haskell by Miran Lipovaca
[http://learnyouahaskell.com/](http://learnyouahaskell.com/)

The latter author decided to write the book based on his experience in
learning Haskell. It's definitely one of the simplest and clearest programming
books I've read.

~~~
GhotiFish
did you get all the way through it?

If you did, you are a substantially smarter person than I.

~~~
jnbiche
Yeah, I got bogged down in monads, but I've promised myself I'll finish it
this year. Learn Yourself a Haskell[...] is extremely well-written and
entertaining, so it deserves completion.

~~~
GhotiFish
I've said the same thing, unfortunately.

All the resources I've seen for Haskell start the same

They are insanely easy to follow at the start, so simple that even first time
programmers won't have much trouble following. Then the type algebra hits and
everything goes out the window.

I've made 3 attempts to get through it. I can even see situations in my work
where monads and monoids may very well be applicable. I still can't work with
Haskell, nor get through any resource that discusses them.

It's possible I'm an idiot, but I suspect my co-workers would fare worse, and
it damns the language in my book.

~~~
mtdewcmu
In college I was required to take a course using SML (which has a type system
that is sort of like Haskell's I think; Haskell's may have been based on it).
I was not all that academically driven that semester, and I was kind of taken
by surprise by how hard the language was, once I started doing the later
projects, and I barely got through the course. That was my only exposure to
functional programming until after college, when I wanted to make up for that
and I undertook to learn Scheme. I didn't have much trouble with Scheme, and
the functional concepts I'd heard about in the course finally made sense. If
you're trying to learn the functional style, I don't see the point in learning
at the same time a complex type system. The type system isn't a natural
consequence of functional programming, it's something that's not really
related but adds a lot of difficulty.

I don't want to start a flame war, but I view types as being sort of
peripheral to the task of getting the computer to do things. If type systems
are getting in the way of programming, priorities are getting mixed up.

~~~
gu
Type systems aren't supposed to "get in the way of programming". Instead, they
are supposed to assist you, and they do. This is why there is the perception
that, for instance, code written in languages like OCaml commonly turns out to
be correct once it compiles correctly. It's certainly not the case that
language designers deploy a complex type system to make your work harder.

~~~
mtdewcmu
I don't question that they're created with the best intentions, but the most
important thing is the end result, not the programming language. And well-
intentioned language features don't always work out like they're supposed to.

~~~
gu
Is this a problem of the language or the person using it?

------
XorNot
Ok so here's the problem I'm having with trying to get into Haskell, and it's
a problem Carmack identified: there's way too many "toy examples" out there.

I've always learned languages because I need them for something. C/C++ because
I wanted to write a game. Python because it's the complex scripting language
of choice in Ubuntu. JavaScript for obvious reasons.

What I really _really_ need is something which walks me through doing
something significant with Haskell - like, a GUI app on Linux or something (my
current focus: I've never really done it, but if I'm learning something new
I'd like there to be a practical product at the end).

A bunch of language constructs, while technically interesting, don't help me
to grok the language at all.

~~~
bnegreve
> _there 's way too many "toy examples" out there._

I am not sure what you mean. Tutorials can only deal with toy examples. Once
you understand them, then you can (and you should) write bigger projects.
About Carmack, that's exactly what he did, he implemented Wolf3D in Haskell to
have a real impression about Haskell. (Assuming you're talking about this
video where he discuss functional programming for games)

Aren't you just being lazy? :)

Edit: that video:

[http://functionaltalks.org/2013/08/26/john-carmack-
thoughts-...](http://functionaltalks.org/2013/08/26/john-carmack-thoughts-on-
haskell/)

~~~
kaoD
I guess he's just as tired as I am of seeing (yet another) quicksort
implementation in Haskell!

99% of the time I spend coding does not deal with data structures or
algorithms, but basic business logic.

How does Haskell perform there? I don't know, but I know Haskell's quicksort
oneliners are pretty (and pretty meaningless too).

I know my way around monads, I'm fluent in functional programming and grasped
typeclasses... but I still can't see what's so great about Haskell beyond
algorithmic beauty. I'd really like to be taught real-world-Haskell just like
I was taught real-world-Lisp.

~~~
bnegreve
Well, I would argue that this article really is _an introduction to functional
programming using Haskell_. Most of the concepts he/she introduce are not
specific to Haskell but are more or less specific to functional programming
languages.

But the author doesn't seem to be very well aware of that. Quoting the
article: _" Haskell is very different. The language uses a lot of concepts I
had never heard about before."_

All that to say that if you already know some functional programming this
probably isn't for you.

Edit: clarity.

~~~
kaoD
Exactly!

Don't get me wrong, I don't think that most Haskell tutorials are inherently
bad, I just couldn't find a good introduction to Haskell targeted at
programmers which are already familiar with functional programming concepts.

------
boothead
How much interest would there be in a 0 to full Haskell development
environment set of ansible scripts (and or Vagrantfile)? I'm working on a
start up using Haskell at the moment and I've been capturing all of my set up
in this way. If folks are interested I can make some of this stuff available.

~~~
Keyframe
What do you install and setup apart from ghc/i?

~~~
boothead
Emacs config. Latest versions of cabal cabal-install. A work around for the
brokenness of the Haskell platform on ubuntu 13.04. Threadscope. Proper cabal
setup for testing. Jenkins setup for CI from the start.

Also investigation dockerizing Haskell services too.

~~~
Peaker
Do you have a good ~/.cabal/config auto-installed with library profiling
enabled?

~~~
boothead
Yes, but I have moved to doing most stuff in sandboxes now and cabal repl is
not playing nice with profiling at the moment.

------
dllthomas
_" Instead of being in your way like in C, C++ or Java, the type system is
here to help you."_

I'd still say the type system is there to help you in C, C++, and Java, it
just doesn't do nearly as good a job of it, and winds up in your way more
often because it's less expressive.

~~~
tieTYT
I'd go as far as to say it doesn't get in your way at all except for
verbosity, I just wish it were better and could do more. I'd love for the type
system to prevent null pointers.

I'm only speaking from Java experience here.

~~~
danieldk
If you are using Java and the JVM: Kotlin[1], a JVM language that attempts to
improve on Java, has non-nullable references.

[http://kotlin.jetbrains.org/](http://kotlin.jetbrains.org/)

------
alkonaut
Learning a functional language is a great idea _especially_ if you never
intend to use one after you've learned it. It's like speaking a second
language. Has a great effect on the understanding of your own language.

At university the first thing everyone had to (in programming) do was a
Haskell course. Felt weird at the time, but in hindsight it was fantastic. It
meant everyone had to throw their preconceptions about programming out the
window.

It didn't occur to me until recently (10-15 years later), that functional
concepts are actually a _good thing_ to apply in any language; that it makes
code parallelizable, modular, maintainable, testable, and so on. I just
thought functional was functional (i.e. elegant but hard) whereas imperative
was imperative (inelegant but easy). Much like the difference between algebra
and arithmetic.

So go learn a second language, or even a third. Even if you intend to speak
english and Java for the rest of your life. I'd choose Haskell and Spanish.

------
virtualwhys
Pretty awesome, I've steered clear of Haskell preferring Scala instead (easier
syntax for me to grok), but this tutorial makes Haskell far more accessible.

Off topic but does anyone know of a Rails/Play + Linq to SQL/ScalaQuery
equivalent in Haskell?

Beyond that just being able to generate PDF invoices, send out emails and have
access to a decent date/time library (like JodaTime) would cover the
essentials for web development.

~~~
ocharles
For Rails/Play, we have three web frameworks:

* Snap * Yesod * Happstack

I think all of these have techniques to build web sites in a modular fashion,
but I have only used Snap myself.

For querying, I personally just use postgresql-simple and write SQL strings,
but this tends to be a major source of runtime bugs so I'm reconsidering that.
For type safe alternatives, we have things like HaskellDB
([http://chrisdone.com/posts/haskelldb-
tutorial](http://chrisdone.com/posts/haskelldb-tutorial)) and esqueleto
([http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Da...](http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Database-
Esqueleto.html)).

We have a fairly decent date time library in time
([http://hackage.haskell.org/package/time](http://hackage.haskell.org/package/time))
but I don't know if that matches JodaTime (because I don't JVM libraries). For
PDF generation I'm actually not sure at all - but have a search on
[http://hackage.haskell.org](http://hackage.haskell.org) and there may be
something.

~~~
enigmo
time (sadly) isn't comparable to Joda Time.

~~~
tel
As someone who has never used Joda Time, what makes it so great?

~~~
virtualwhys
Generally immutable (supports mutable state for some edge cases) along
incredibly rich functionality covering everything you could imagine needing
time-wise, and does so concisely.

It's a godsend given the built-in Java alternative.

------
6ren
ASIDE: I've been using _learn you a haskell for great good!_
[http://learnyouahaskell.com/](http://learnyouahaskell.com/), and found it
helpful, insightful and the examples nicely paced so you can treat them as
exercises as you go.... up until the module chapter, which is more like a
reference, very long, detailed, tedious. I got up to here
[http://learnyouahaskell.com/modules#data-
char](http://learnyouahaskell.com/modules#data-char) (check out how small the
scroll bar slider is on the right - this is a big chapter).

Did this stop you or how did get past it?

How does _Learn Haskell Fast and Hard_ compare?

~~~
merijnv
After that chapter it goes on the same way as before. I think the chapter is
just a reference for "good places for beginners to get acquainted with".

------
JonCox
If you want to learn Haskell slow and easy, this is brilliant:
[http://learnyouahaskell.com/chapters](http://learnyouahaskell.com/chapters)

------
616c
I have been perusing Learn You a Haskell but I like this more. Fast and hard
indeed. Will read this over tonight.

~~~
merijnv
Word of warning, though. While this article looks pretty decent it's skipping
over lots of tiny details that are covered in LYAH, which may lead to annoying
gaps in your knowledge/understanding later.

------
AnthonBerg
PERFECT. Relaxed but intense. Perfect! ... for me. This is exactly the kind of
tutorial that works best for me. (I'm sure many people will find it unusuable.
But that's OK - we have as many ways to learn as we have learners.)

The selection of artwork is pretty nice too.

Very very good. Thank you author and poster.

------
carterschonwald
NB: if you're trying out haskell and you're on a mac with xcode 5, you'll be
hitting some weird CPP related errors due to GHC 7.6 and older not playing
nice with Clang's CPP.

I shared a number of work arounds with the general haskell community a few
weeks ago here: [http://www.haskell.org/pipermail/haskell-
cafe/2013-September...](http://www.haskell.org/pipermail/haskell-
cafe/2013-September/110320.html) (there are alternative work arounds, but I
only listed the ones which are simple and easy to communicate with other
people and be able to expect them to follow the steps correctly.)

------
anuragramdasan
I have been wanting to look into Haskell for a long time now. Never really got
the time. Also the syntax was a bit off putting.

Just skimmed through. I see that there is a bit of Javascript and C in the
code too as reference matertial. Most people dont like such a way of teaching
but it looks like the tutorial isnt really trying to teach Haskell in terms of
Javascript or C. Really makes me want to look into this. Thanks for putting
the efforts.

~~~
IsTom
I'm a bit surprised that you say the syntax if offputting, most people I've
met say otherwise. Could you point to something you specifically don't like?

~~~
anuragramdasan
I didnt mean in a sense that it sucks. Its way different from the traditional
C style or Lisp style syntax that I've used. Regardless of whether it is good
or bad, it would have taken me some time to adjust to it and I never had that
kind of time.

Also as someone who doesn't know Haskell at all, I have great difficulty
reading Haskell. I dont think I would have that kind of problem reading a
language with a more traditional syntax.

~~~
doorhammer
I think some folks are misreading your comments a bit as an indictment of the
language. I read it as saying, "Haskell doesn't have syntax that's similar to
any language I know and that means I have to learn something I don't know,
which takes time, and I don't have a lot of time."

Personally, I'm with you. I've used other functional languages (F#, clojure,
erlang), I'd say I'm pretty familiar with a lot of the ideas Haskell uses
(comprehensions, partial application, anonymous functions, pure functions,
pattern matching) and I actually _really_ want to learn Haskell, but I have a
hard time intuiting the meaning of a lot of Haskell syntax just based on other
syntax that I know.

I also realize that the syntax probably fits the language very well, which
makes sense, and that it's a good thing. I wouldn't want it to compromise it's
purity for familiarity. Just makes it more work to learn.

~~~
anuragramdasan
Hah! yes. Maybe I should have put it the way you did.

My view of Haskell is the same as a non-Lispers view of Lisp. Cry about too
much parens and it making things difficult to understand. Doesn't mean the
language needs to be changed. I am all in for learning Haskell although most
introductions to haskell are really time consuming and dense, so I never just
did it. Which is where I was really glad that this tutorial was put up.

Hating any language which actually does serve its purpose is pretty stupid. If
anyone actually has some issues understanding a sightly different but very
well respected language, then the fault is mostly with that person and not the
language.

~~~
doorhammer
I think lisp is a really good example for how I feel with haskell, and one I'm
more familiar with.

When I first started learning lisp, the syntax was foreign, and while lisp
syntax is arguably really really simple, composition with that syntax is a
little weird if you're not used to it. Yet, at the same time, the syntax is a
fundamental part of the language, especially with respect to homoiconicity,
simplicity and macros. It was a time-sink to get used to it, but totally worth
it.

~~~
anuragramdasan
very much agreed.

------
ufo
Minor nitpick: Using pattern matching instead of `if xs == []` is not just to
make code prettier and cleaner.

First of all, you should be using the `null` function instead of `== xs`
because the `==` operator only works if your list contents are Eq-able.

But the most important thing is that pattern matching is more type safe. If
you use `head` and `tail` you, as a programmer, need to make sure that you
only call them on a non-empty lists or else you get an error. On the other
hand, if you use pattern matching the compiler helps you make sure that you
always covered all the possible cases (empty vs non-empty) and you never need
to worry about calling the unsafe head and tail functions.

------
asgard1024
I really like the art images in the tutorial. Nice touch.

Although I am not sure about the premise - I doubt Haskell, as a language
close to mathematics, can be learned fast. This tutorial seems quite shallow
on some things, like monads.

~~~
asdasf
It does sort of bail on you instead of explaining what monads are. A couple of
examples of monads is not the same as understanding what the underlying
abstraction is. That said, it isn't hard or long to learn monads. A monad is
something that can be mapped over and concatenated.

~~~
asgard1024
> That said, it isn't hard or long to learn monads.

I am not sure any definition does that justice. It's similar with concept of
recursion - it's easy to define (function calls itself), but to put it into
programming practice (writing all loops as recursion), that's a lot harder.

I read "Learn Yourself a Haskell" as a tutorial (which is in my opinion great)
and still it was a lot of work to figure out this:
[http://blog.tmorris.net/posts/20-intermediate-haskell-
exerci...](http://blog.tmorris.net/posts/20-intermediate-haskell-exercises/)

Then I started reading
[http://www.haskell.org/haskellwiki/All_About_Monads](http://www.haskell.org/haskellwiki/All_About_Monads)
but didn't finish it yet (I was playing with Haskell, just figuring out how to
structure the application). IMHO, unless you understand all that, how to put
monad concept into practice, you don't really know monads.

------
tieTYT
I'd like one of these beginner tutorials to have a chapter named, "learning
cabal and using a library". That was a pain point for me (especially
developing on windows). Well, not so much a pain point as a mortal wound.

------
arunc
Thinking about Haskell, reminds me of this
[http://www.xent.com/pipermail/fork/Week-of-
Mon-20070219/0441...](http://www.xent.com/pipermail/fork/Week-of-
Mon-20070219/044101.html)

------
tlo
Nice tutorial, but old story:
[https://news.ycombinator.com/item?id=3806841](https://news.ycombinator.com/item?id=3806841)

------
fmax30
Okay so i completed this tutorial in about 5 hours , gave everything due , but
still i only understand like 30 % of it and that too of the starting part.

------
cnu
Check out [http://learnxinyminutes.com/](http://learnxinyminutes.com/). Loads
of languages/tools to learn.

------
pa5tabear
Commenting to bookmark.

~~~
Jtsummers
If you upvote an article on HN then it shows up via the "Saved Stories"[1]
link in your profile (not visible to others).

[https://news.ycombinator.com/saved?id=pa5tabear](https://news.ycombinator.com/saved?id=pa5tabear)

------
batgaijin
a monad is like a taco salad.

------
RyanZAG
I haven't seen this Haskell syntax before:

    
    
      [1,3..10] ⇔ [1,3,5,7,9]
    

Imagine running into this one on a production system... Someone needs to make
a 'Haskell: the good parts' or at least a lint.

~~~
merijnv
How is that weird, it's just uses the increment from the first to second value
as step and repeat as long as it's smaller than the end value. Python does the
exact same thing:

    
    
        Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
        [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
        Type "help", "copyright", "credits" or "license" for more information.
        >>> range(1, 10, 2)
        [1, 3, 5, 7, 9]

