News for hackers. Stuff that matters.
Re:Haskell Concepts in One Sentence by xelxebar on Sunday March 26, 2017 @04:43AM (#13959819)
Well, you really do need the full Kleisli triple and commutation laws, otherwise bind becomes just a functor.
Re:Haskell Concepts in One Sentence by scottmsul on Sunday March 26, 2017 @10:43AM (#13961012)
That's not exactly true, since bind and fmap have different types.

fmap :: (Functor f) => f a -> (a -> b) -> f b

bind :: (Monad m) => m a -> (a -> m b) -> m b

Functors simply map elements one-to-one, while monads map elements to new data structures, which have to be combined back to a single data structure.

However, it's good you mention the laws - it's certainly possible to define bind with the correct type but incorrect behavior. An example would be defining the List bind in a way that doesn't concatenate the elements in order.

The following is a really good reference for understanding not just the difference between functors, applicatives, and monads, but also why each is more powerful than the one before it.

https://en.wikibooks.org/wiki/Haskell/Applicative_functors#A...