[Haskell-cafe] Explaining monads
David Menendez
zednenem at psualum.com
Sat Aug 11 03:32:30 EDT 2007
On 8/10/07, Ronald Guida <ronguida at mindspring.com> wrote:
>
> Kim-Ee Yeoh wrote:
> > Monads are undoubtedly more pervasive, and that could be because there
> > aren't as many arrow and comonad tutorials, atomic ones or otherwise.
>
> Moreover, Comonad isn't even in the standard libraries (Hoogle returns
> no results for it).
This is probably because no one has found a compelling use case for
comonadic-style programming in Haskell. There have been some
interesting papers, such as "Comonadic functional attribute
evaluation" by Uustalu and Vene, but nothing as compelling as Wadler's
"Monads for functional programming".
> In my case, I have started to formulate my own idea for what a monad
> tutorial should be; I might attempt to write one, too.
Be sure to read sigpfe's "You could have invented monads!" and the Wadler paper.
<http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html>
<http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf>
Most tutorials try to explain what a monad *is*, but these focus more
on why they're a useful way to organize code. In my experience, being
able to use a monad is more important than understanding the theory.
> Also, arrows are supposed to be more general than both monads and
> comonads. If I could just figure out what each structure (functor,
> monad, comonad, arrow) is doing, and compare and contrast them, then I
> probably will have made leaps of understanding.
Arrows are more general than monads and comonads in the sense that you
can create an arrow corresponding to any particular monad and comonad,
but there are also arrows which correspond to neither.
Functors are more general than monads and comonads simply because
every monad and comonad is a functor with additional operations. (This
can be obscured by the fact that the Haskell Prelude doesn't define
Monad as a subclass of Functor.)
More information about the Haskell-Cafe
mailing list