Naming is one area where Haskell's academic background is more curse than blessing. Numerous tutorials and blog posts would never have been written if only functor was named mappable and monad was named computation builder. They're named by analogy to category theory, but their usage in computer science is not at all similar.
Here's the next article in the series:<p><a href="http://slpopejoy.github.io/posts/Effectful02.html" rel="nofollow">http://slpopejoy.github.io/posts/Effectful02.html</a>
I was interested and pleased to note that the source for this post is available in Literate Haskell: <a href="https://github.com/slpopejoy/tatterdemalion/blob/working/posts/Effectful01.lhs" rel="nofollow">https://github.com/slpopejoy/tatterdemalion/blob/working/pos...</a>
Something I've wondered about: How does Haskell not optimize away IO ()? In a pure, functional languages, a function that doesn't return anything can simply be eliminated — but of course it isn't.<p>I've always assumed that Haskell's compiler has a built-in rules about IO having side effects, but I never actually bothered to find out.<p>When I first started with Haskell, one of many small epiphanies was when I realized that the IO monad itself doesn't actually <i>do</i> anything. bind and return don't do anything except wrap and unwrap values, and there's nothing that checks if you are in some kind of "IO context" to permit things like file I/O. There's no magical "side-effectful computation chain engine" behind the scenes.
"We can see therefore how Monad offers strictly more powerful transformations than Functor. fmap can only transform an individual value “in place”, while >>= can return an empty list, or a list with more elements than the original. Functor is “structure preserving”, while Monad is “structure transforming”."<p>So for a list monad
bind = flatMap
fmap = map<p>is that correct?<p>Studying FP for quite a while first monad tutorial I come to fully understand finally.
So is it possible to explain monads with Javascript ? or even LISP ? seems to me monads == haskell so if one doesn't understand haskell one can't understand monads , cause all monad tutorials are written in haskell. So I ask , what is the point of learning what a monad is if i'm writing some Java ?