4 ms·
A nice tutorial. By the way, Monads are an interesting pattern. But far from the only type class that useful in Haskell. The Typeclassopidea (in http://www.h
by eru 16y ago
A nice tutorial. By the way, Monads are an interesting pattern. But far from the only type class that useful in Haskell. The Typeclassopidea (in http://www.haskell.org/sitewiki/images/8/85/TMR-Issue13.pdf http://www.haskell.org/sitewiki/images/8/85/TMR-Issue13.pdf) gives a nice overview. I find Arrows especially interesting at the moment, but that probably because I already know Monads, Functors and pointed Functors quite well.
Conal Elliott has an interesting blog post talking showing how to use Arrows as semantic editor combinators (http://conal.net/blog/posts/semantic-editor-combinators/ http://conal.net/blog/posts/semantic-editor-combinators/). It's enough to get you started on arrows with a useful application. (Of course, as with Monads, arrows are much more than this one application. But seeing one concrete application is a good start for your imagination.)
- dododo 16y agoMonads are a special case of Arrows. You can think of Arrows as generalised functions: the type of a function is X -> Y, whilst the type of an arrow is A X Y, where A takes the place of the infix type ->. So another way you can write the type of a function is (->) X Y, from this (+ technicalities) we see that functions are Arrows. Monads are a special case of arrows where A X Y becomes X -> M Y or (without the infix syntactic sugar) (->) X (M Y); Monads can take control of the outputs from operations, whilst Arrows can take control of both the input and output to operations. I found Monads made a lot more sense after I learnt about Arrows because Arrows are what I wanted Monads to be. btw, the "killer app" for monads, imho, is parsec: http://legacy.cs.uu.nl/daan/parsec.html http://legacy.cs.uu.nl/daan/parsec.html whilst the "killer app" for arrows is probably FRP: http://www.haskell.org/haskellwiki/Functional_Reactive_Programming http://www.haskell.org/haskellwiki/Functional_Reactive_Progr...
- eru 16y agoYes. And Monads are also a special case of Functors (and of Pointed Functors). Interestingly, Functors and Arrows are different generalizations of Monads, and neither is a generalization of the other. I also agree with Parsec being the killer application of Monads. In a purely functional setting Input/Output and similar things suffice as a motivation for monads, but that won't excite any Java programmer. But using Monads for a parser, like Parsec does, would also be a good idea in Java.
- intoverfl0w 16y agoCouldn't agree more on all points, particularly the last two.