3 ms·
For me this has been really useful. While I somewhat have a noob understanding of Haskell, and some experience with monads, the parallels between composing fun
by ToJans 11y ago
For me this has been really useful.
While I somewhat have a noob understanding of Haskell, and some experience with monads, the parallels between composing functions (i.e. "id" & (.) ) and composing monads i.e. "return" & (<=<) never really occurred to me. Now that I've seen this, I'll probably start looking for similar patterns in other places.
This has been what made Haskell click for me: the minute you start doing something that is slightly repetitive, like a for loop including a continue/break, parallelizing code or using if error/null all the time, there's a pattern there. Haskellers recognize these patterns, and implement them once, so you can reuse them and avoid making mistakes by implementing something similar yourself every single time. Having this opportunity makes your code more shorter and concise, and instead of implementing something yourself, you can use these battle-tested implementations to model your code. (And thus avoid those annoying not-null/if error bugs for example.)
Even though Haskell might not be suitable for every problem domain, I found out it really shines by it's explicitness. You model your domain using types for intermediate states, and the exercise of converting one type to another is rather trivial. (f.e. a sudoku solver [3]).
The biggest problem for me personally has been my inability to speak the category theory language, but I'm learning... I also believe that the basic Haskell libs need examples next to their descriptions, because most of us learn by example. [1] If I can see what a maybe monad is for, I can start using it without properly understanding monads. After a while you'll have seen enough different types of monads to understand their use case. IMO one language implementer that understood this extremely well is José Valim, just take a look at the Elixir docs for data.list. [2]
Because Haskell has been mostly implemented by mathematicians and computer scientists, they assume basic upfront knowledge. This is what makes it hard for beginners. What we really need in the Haskell world is some cognitive bias mitigation. YMMV.
* [1]: https://www.reddit.com/r/haskell/comments/3rhpyq/as_a_haskell_noob_i_think_docs_need_more_examples/ https://www.reddit.com/r/haskell/comments/3rhpyq/as_a_haskel...
* [2]: http://elixir-lang.org/docs/stable/elixir/List.html#functions http://elixir-lang.org/docs/stable/elixir/List.html#function...
* [3]: https://github.com/ToJans/learninghaskell/blob/master/0003%20Sudoku.hs https://github.com/ToJans/learninghaskell/blob/master/0003%2...