Quantcast
Channel: Chaos Folded
Viewing all articles
Browse latest Browse all 10

Understanding Haskell monads

$
0
0

I’m proud to announce that I have completed my first monads tutorial for Haskell programmers. Although I’m not completely happy with a few parts (I’m a virgo after all), I’m releasing it now. I hope it will be helpful to the community.

Read the tutorial

Comments

catechu:

Coincidentally, your suggestion on Usenet today to learn more about monads brought me to your tutorial.

The phrase “category theory” is tossed around a lot, but although I find plenty of tutorials about monads, it’s not clear to me how monads connect to the underlying category theory. Understanding this connection — or, at least, pointing to references which explain it from a mathematical perspective — would probably make monads seem less arbitrary. What do you think?

December 26, 2008 10:38 PM

ertes:

Yes, in fact, Haskell monads are a special case of the monads from category theory. The good thing about Haskell monads is that they can be understood without needing to learn category theory, and this is really the preferred way to go. My experience is that category theory confuses people even more, so going into it would probably be worse than not mentioning it at all.

To someone, who is foreign in the category theory world, monads appear just as arbitrary as Peano’s idea of natural numbers appears to someone, who hasn’t yet known about numbers. A better comparison would be structures from group theory. They are similarly abstract.

The power of monads comes from this abstraction. You implement functionality at a much more general level than you would for particular monads. I hoped to have addressed this motivation well in my tutorial.

As a comparison, consider groups from group theory. You analyze the abstract structure and find theorems and corresponding proofs about it. Whenever you find that a structure is a group, those proofs apply automatically.

Trying to interpret the general monad structure is like trying to find a better name for it.

December 27, 2008 3:14 AM

catechu:

“My experience is that category theory confuses people even more, so going into it would probably be worse than not mentioning it at all.”

Thanks for pointing this out. I’ll take your word for it, and continue to climb Mount Monad by reading your tutorial.

December 27, 2008 7:33 AM

linker:

Hey, good work. I especially liked how you mentioned uniqueness typing of Clean (haven’t seen this in other tutorials).

The section on monad transformers is too short I think, but still, the examples you give are good enough to justify the terseness.

Keep it up!

December 28, 2008 5:14 PM

Benjamin:

Great tutorial that nailed it for me.
Having some background in functional programming (as well as in imperative programming), this tutorial did what other tutorials - for some reason or other - couldn’t:
It demystified the inner workings of monads.

January 21, 2009 4:23 PM


Viewing all articles
Browse latest Browse all 10

Trending Articles