Hacker News new | ask | show | jobs
Inside My World – Ode to Functor and Monad (blog.jle.im)
12 points by jle 4415 days ago
2 comments

Outstanding explanation.

I think it's so good partly because I had come up with a similar explanation ;-) but it turns out that my explanation for a Monad was actually more correctly the explanation for a Functor :-(

I might tweak it slightly: Explain that a Monad really is an algebraic monad, and that it really needs to be that, not just because that's what the function signatures wind up being, but because Haskell is, under the hood, expecting it to satisfy the monad identities. (Or do I have that wrong?)

In one of the Reactive Programming Scala class on Coursera, one of the teachers said types only need to satisfy 2 of the 3 Monad laws to be useful in for comprehensions (similar to do blocks in Haskell), so it didn't actually matter whether they satisfied the 3rd law. Monads do need to have at least those 2 properties, though. (I don't remember at the moment whether it was the right or left identity law that was unnecessary)
Thanks!

I do mention that instances of the Monad typeclass have to follow certain laws to make sure that they are "meaningful and useful"...I handwaved the actual laws away in the ambiguous interpretations of 'meaningful and useful' :) I made the choice that going into what that really meant would be beyond the scope of the article...but thanks for the comment :)

Hi, author here; experimenting with some ways to explain two very useful concepts that I feel don't get enough mainstream popularity, despite being applicable to many languages :) Let me know if there are any obvious mistakes, awfully written sections, or questions :)