[Haskell-cafe] Explaining monads
stefanor at cox.net
Sat Aug 11 15:17:16 EDT 2007
On Sat, Aug 11, 2007 at 03:00:04PM -0400, Ronald Guida wrote:
> The question remains: "What is special about Monad or ArrowApply,
> compared to Arrow?" or "What is more general about Arrow, compared to
> Monad or ArrowApply?"
If all you have is an Arrow, then you must make up your mind what you're
going to do ahead of time.
ArrowChoice gives you the ability to make basic "yes or no" decisions at
ArrowApply gives you arbitrary computed jumps.
Sometimes it's useful to restrict what you can do. Duponcheel and
Swierstra wrote a parser library as an Arrow; because it forced you to
decide the parsing structure ahead of time, their library had enough
information to build LR-type parsing tables, and thus to do yacc-style
error correction. (Nobody found it useful enough to use, but it still
makes a nice demonstration of why plain Arrow is sometimes better.)
Conversely, some applications *need* the extra freedom. Imagine trying
to write an interpreter for a toy language with I/O, and IO is a plain
Arrow and not a Monad. You can read input and parse it, but you can't
actually do IO because the IO you need to do, depends on the input you
read - precisely what Arrow forbids!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070811/91a863a8/attachment.bin
More information about the Haskell-Cafe