I don't really know where to start, but I'll point out that passing parameters to a function is not "monadic style", it's just passing parameters to a function. The article suggests that given a function of one argument, it's better to put the argument in a global variable and then have that function read the global variable than it is to just pass the parameter to the function directly. I find this to be confusing, convoluted, hard to reason about, and generally unmaintainable. (What if the function calls itself?)
Also, side-effects aren't "bad" and you aren't "sinning". It's just hard to reason about what happens when side-effect-causing units are composed with each other. The Ruby approach is to hope nothing bad happens; the Haskell approach is to let the type system ensure that nothing bad happens. Many people like to make their code robust, so they try to avoid unstructured side-effects.
One more unrelated tidbit, I had trouble understanding "monads" until I realized that "monad" is an adjective, not a noun. You can't go out and buy a "monad", just like you can't go out and buy a "red". "monadic" is a property of a type (like "red" is a property of a strawberry). "monad" is just a convenient way to say "a type that is monadic" with less syllables. Once you are happy with that, Haskell is really easy.
1 comment
[ 3.0 ms ] story [ 10.2 ms ] threadAlso, side-effects aren't "bad" and you aren't "sinning". It's just hard to reason about what happens when side-effect-causing units are composed with each other. The Ruby approach is to hope nothing bad happens; the Haskell approach is to let the type system ensure that nothing bad happens. Many people like to make their code robust, so they try to avoid unstructured side-effects.
One more unrelated tidbit, I had trouble understanding "monads" until I realized that "monad" is an adjective, not a noun. You can't go out and buy a "monad", just like you can't go out and buy a "red". "monadic" is a property of a type (like "red" is a property of a strawberry). "monad" is just a convenient way to say "a type that is monadic" with less syllables. Once you are happy with that, Haskell is really easy.