Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The Haskell Phrasebook (2019) (typeclasses.com)
104 points by bshanks on July 3, 2021 | hide | past | favorite | 12 comments


This is a great way to teach Haskell! The authors taught beginners at Zurihac 2020 and were great at explaining the 'harder' concepts like monads too

Edit: by the way, if you're wanting to learn or struggling to learn monads, you can't go wrong reading the literature at the time. Seeing how Haskell originally used types and pattern matching to IO and how hard it was to do things like logging, and then how monads fix that, is the absolute best way to approach the subject. SPJ and Wadler are the authors of those papers.


Talking about monads, I found Railway Oriented Programming [1] and "Understanding map and apply" [2] (and the whole serie) really interesting. I liked the notion of lifting types to an "elevated world".

[1] https://fsharpforfunandprofit.com/rop/ [2] https://fsharpforfunandprofit.com/posts/elevated-world/


Yeah I agree!


Could someone link us to that literature?


Tackling the Awkward Squad by SPJ is a good starting point, it'll link to the other literature


Pretty cool. They note that they are inspired by Go by Example [0] and Rust by Example [1], and this book seems stylistically similar to the community-driven Learn X in Y minutes site [2] which covers quick syntax/conceptual overviews for many other languages as well.

For the same target audience looking for free introductory coursework/exercises for Haskell, I'd recommend working through the Data61 Haskell course [3]. Brian McKenna has a nice Youtube series [4] covering it.

[0] https://gobyexample.com/

[1] https://doc.rust-lang.org/rust-by-example/index.html

[2] https://learnxinyminutes.com/

[3] https://github.com/system-f/fp-course#readme

[4] https://www.youtube.com/watch?v=NzIZzvbplSM


It's fun.

It starts with stuff that makes Haskell look like an unimposing imperative language, like Python.

It may be a good idea for the introduction: instead of presenting the wall of ideas that make Haskell interesting and unusual, first offer the do-notation that makes Haskell feel familiar, and make the reader feel confident quickly. Introduce "variables", first, immutability and monads that power them much later.


Yeah but if you make a small mistake you'll quickly be confronted with the underlying mechanics anyway, in the form of an inexplicable error message.


From the "defining functions" example (https://typeclasses.com/phrasebook/defining-functions):

  greetNext x = (next x, greet (show (next x)))
Is this actually valid, unambiguous code? What determines which `next x` gets evaluated first?

(edit: oh, nvm, x isn't a state, so both `next x` evaluate to the same value)


> x isn't a state, so both `next x` evaluate to the same value

Yes. More generally, Haskell functions are pure (side-effect free), so you always expect the same input value to result in the same output.


And they first explain "show" in the following passage.

I wish they had run more novices through these phrases.


Absolutely brilliant content




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: