Practical uses of monads in Haskell
Posted by nicuveo@reddit | programming | View on Reddit | 4 comments
Inspired by a question on r/haskellquestions, i wrote about the practical aspect of monads for people at a beginner / intermediate level, about how to go beyond mere understanding the monad class. I try to highlight how we use monads to structure our code, what benefits they bring, and how to reason about them. it comes with exercises!
VictoryMotel@reddit
All of haskell is silver bullet syndrome that accomplishes nothing.
Just make simple data structures, loop through arrays and look up in hash maps. Haskell just complicates things that aren't difficult in the first place.
Delta-9-@reddit
Fun fact: lists are monads.
Monads aren't that complicated. The big leap from procedural to monadic styles is the same as the leap from procedural to functional style: monads pretty much require you to think in terms of function composition (they're basically functions themselves), which feels weird and complicated if you're headspace is filled with for-loops and if-statements.
PragmaticFive@reddit
I can't take that alien notation (>>=) serious.
nicuveo@reddit (OP)
yeah, C++ really dropped the ball with their bitwise right shift assignment operator.
but more seriously, yeah, when i was teaching Haskell, i used to refer to this as the "curse of Haskell": you can create your own operators! it's trivial to do so, they're just functions. it's fantastic if you want to create DSLs, but it can very easily be abused and make your code completely unreadable. finding the right balance comes with experience. ^^