Live data from Hacker News

Ask HN: What resources do you recommend for learning Haskell?

news.ycombinator.com

51–60 of 67 posts

Re: Ask HN: What resources do you recommend for learning Haskell?

#51
Here's the reading list I created for the undergrad module I taught:

Haskell

Books:

- Maybe Haskell by Pat Brisbin [https://thoughtbot.gumroad.com/l/maybe-haskell]: Very good book, available under a "pay what you want" model (or free pdf here [https://books.thoughtbot.com/books/maybe-haskell.html]).

- Learn you a Haskell for Great Good by Miran Lipvača: Available to read online for free [http://www.learnyouahaskell.com/].

- Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen: Available to read online for free [http://book.realworldhaskell.org/read/].

Online tutorials:

- List of resources on haskell.org

- Haskell Wiki [https://wiki.haskell.org/Haskell]

- The Basics of Haskell series [https://www.schoolofhaskell.com/school/starting-with-haskell...] by Bartosz Milewski, from the School of Haskell website [https://www.schoolofhaskell.com/] (which also contains a number of other great resources on Haskell more generally).

- The Haskell Phrasebook [https://typeclasses.com/phrasebook]: a free quick-start Haskell guide comprised of a sequence of small annotated programs. It stands out from more traditional Haskell tutorials in that, instead of using the principles of Functional Programming as the theoretical starting point from which to start introducing the motivation and syntax of Haskell as a programming language, instead, it introduces Haskell syntax directly using code snippets that mimic traditional imperative programming as much as possible. This is intended to help users coming from imperative languages familiarise themselves with Haskell syntax first, and then slowly build on that by using progressively more idiomatic Haskell code, motivating its suitability for Functional Programming.

Other:

- The Hoogle Search Engine [https://hoogle.haskell.org/]; search for haskell operators or expressions here to get information on them. Good for looking up functions and operators defined in the Prelude (the haskell standard library) and other modules.

- List of haskell reserved symbols and keywords with brief description / explanations [https://wiki.haskell.org/Keywords].

Re: Ask HN: What resources do you recommend for learning Haskell?

#52
post #21

Perhaps contrary to most people in this thread, I think you should avoid learning lenses or category theory too early. These are great tools, but they take months or even years to master and are not required to write useful code in the language. I find Haskell very useful for my projects, but to achieve this I restrict myself to the basic subset of the language (Haskell 2010, no fancy extensions such as type families…

    type JokeM a = IO a

    askQuestion :: JokeM String
    askQuestion = do
      putStr "How do you know someone works at Jane Street? "
      hFlush stdout
      getLine

    tellPunchline :: String -> JokeM ()
    tellPunchline _ = putStrLn "They tell you!"

    janeStreetJoke :: JokeM ()
    janeStreetJoke = askQuestion >>= tellPunchline

    main :: IO ()
    main = forever janeStreetJoke
I don't know this feels kind of verbose to me.

Re: Ask HN: What resources do you recommend for learning Haskell?

#53
post #19

Haven’t touched Haskell in years, but I found the best guide was Brent Yorgey’s old UPenn CIS194 online class. It contains easy to digest text lectures with follow up classwork. I successfully taught dozens of people who had no former functional background. Just did a weekly meeting covering the lecture and prior week’s homework. https://www.cis.upenn.edu/~cis1940/spring13/lectures.html

I also found this course to be a great resource!

Re: Ask HN: What resources do you recommend for learning Haskell?

#54
post #50

Earlier quoted context omitted.

As with anything Haskell, one could simply reply with "here's the formal definition." But in easily digestible terms, it's a way to narrow your view over a collection to a subset that satisfies some property, and perhaps perform some operations on that subset. This video presentation (with a very humorous audience dynamic, might I add) serves as a great introduction by example: https://youtube.com/watch?v=QZy4Yml3LTY

I'm going to watch the video, but I'm having trouble understanding how lenses are different from filter, and perhaps map. Is it just a combination of filter and map?

No, it's quite different. A super rough but somewhat accurate starting point is to think of a lens as being like the `.foo.bar.baz` in `myobject.foo.bar.baz`: a way to describe some "location" inside of a data structure, in a way that allows for getting and setting. But lenses are also data, so they can be stored in variables, manipulated, and so on. It's a very useful concept, and very much not required or helpful when learning Haskell. It's also not a core Haskell concept in any sense, just something that has been built on top of Haskell as a library.

Re: Ask HN: What resources do you recommend for learning Haskell?

#55
post #50

Earlier quoted context omitted.

I'm going to watch the video, but I'm having trouble understanding how lenses are different from filter, and perhaps map. Is it just a combination of filter and map?

No, it's quite different. A super rough but somewhat accurate starting point is to think of a lens as being like the `.foo.bar.baz` in `myobject.foo.bar.baz`: a way to describe some "location" inside of a data structure, in a way that allows for getting and setting. But lenses are also data, so they can be stored in variables, manipulated, and so on. It's a very useful concept, and very much not required or helpful w…

Also helpful to note that the "location" can be virtual. For example you could have a lens into the hours field a string that contains an ISO-8601 formatted date, so you could do something like

    let s = "20240722T193456.789-0800"
    putStrLn $ 19840206T193456.789-0800  -- prints "20240722T203456.789-0800"
and they can be composed, so if you have some other lens that gets from your outer structure to an ISO-8601 formatted date string field, let's call that lens `fieldLens` then `fieldLens . hours` will get from your outer structure to the hours field of that date field.

Re: Ask HN: What resources do you recommend for learning Haskell?

#57
My biggest difficulty in learning Haskell was to distinguish the really useful from the useless. There is a lot of “academic nonsense” in Haskell (both in the language and in the code people have written) and a lot that is just broken and abandoned or unnecessarily complicated. Unfortunately, it takes a lot of time to separate the wheat from the chaff. Underneath the 50 or so language extensions, the completely outdated (and in my opinion broken) Prelude and the super frustrating and unpolished tooling and cursed lazyness hides a very beautiful and powerful, simple, productive, purely functional programming language.

To summarize, you could say that Haskell is not really made of one piece, but is something like a 34 year old, very messy academic playground.

So it might be helpful to switch to a purely functional alternative, Purescript/Elm/Gren for practical programming, or Idris/Agda to explore the more academic side.

Re: Ask HN: What resources do you recommend for learning Haskell?

#58
Not yet mentioned: https://leanpub.com/haskell-cookbook, a good intro from an experienced tech writer.

If you like videos: https://www.youtube.com/results?search_query=haskell

The haskell matrix room and (slightly less useful for beginners) IRC channel: https://www.haskell.org/community

Curated resources:

https://www.extrema.is/articles/haskell-books

https://www.haskell.org/documentation

https://haskell-links.org

Re: Ask HN: What resources do you recommend for learning Haskell?

#60
I learned a great deal by working through a bunch of haskell coding puzzles on codewars after only reading the first six chapters.

This helped a bunch with getting good at higher order functions and recursion.

I took a detour to lisp after and never looked back, but that's due to my type system preferences, you'll benefit from puzzles either way.

Post reply on HN