I understand monads

By 8 nic on March 08, 2007

Embed Claim Make a related claim

Discussion (5)

http://www.tapsellferrier.co.uk/nicferrier/

8 nic who disagreed, says

@jay cred given. now explain them!

Make a related claim about 1 year ago (link)
http://meangrape.myopenid.com/

3 Jay who agreed, says

Oh, man, called out.

OK. This isn't going to be perfectly precise because it's too abstract for me to spend the time explaining in all of its gory detail, besides, my category theory is weak. What follows is very hand-wavey.

There are two groups (G,*) and (H,+). There is a function f: G -> H such that for all x, y in G f(x * y) = f(x) + f(y). f is a homomorphic -- structure preserving -- function.

Now we're going to abstract the notion of a homomorphic function over groups to a function M that preserves some form of structure over 2 mathematical objects -- sets, groups, topological spaces, what-have-you). M is a morphic 'function' (not that M has to be a function or the objects that it acts on have to be sets).

F is a functor (I don't think I've used capital F yet) -- a special case of a morphism. F is analogous to f in that given two objects, J and K, and given all morphisms('functions') T: J -> K, F preserves identity morphisms and the composition of morphisms.

Still with me?

There are two functors, F' and F'' such that (F'x,y) = (x,F''y). F' and F'' are adjoint. F' is left adjoint to F''. A monad is the composition F'' o F'.

Bet you thought I was going to talk about Haskell, eh?

Make a related claim about 1 year ago (link)
http://meangrape.myopenid.com/

3 Jay who agreed, says

Oh, neat. I just went and looked up functors and monads in the Haskell docs and my comment explains exactly what they do.

Functors preserve identity and composition:
fmap id == id
fmap (f . g) == fmap f . fmap g

Monads are the composition F'' o F':
return a >>= k == k a

Make a related claim about 1 year ago (link)
http://www.tapsellferrier.co.uk/nicferrier/

8 nic who disagreed, says

didn't understand a word of it.

Make a related claim about 1 year ago (link)
http://meangrape.myopenid.com/

3 Jay who agreed, says

Mmmm. From a programming perspective they're probably good for...storing state or building big operations out of little functions, I'd guess.

They're so abstract it's hard to relate them to much of anything.

Make a related claim about 1 year ago (link)
Sign in in to leave a comment.