[Haskell-cafe] Explaining monads
Jeff Polakow
jeff.polakow at db.com
Tue Aug 14 14:57:46 EDT 2007
Hello,
> On 14/08/07, Jeff Polakow <jeff.polakow at db.com> wrote:
> Of course, the type [Int] denotes a value which is a list of Ints;
> additionally [Int] can be viewed as a value representing the
> nondeterministic computation of a single Int. Generally, the type
> Monad m => m Int can be viewed as a value representing the
> computation of an Int.
>
>
> But thats not really right. What exactly m Int does /depends/ on m.
> It might represent 0 or more computations
> of Int, or computations of Int carrying some extra stuff around, or
> complex control logic about what the computation does
> when.
>
Perhaps the confusion is in the word computation. I'm using the word in an
abstract sense. I do not mean the actual execution of Haskell code to
produce a value. Thus, under this intuition:
The type Int represents a value which denotes an Int. The type m Int
denotes a value which is a single computation (for an unspecified notion
of computation) of an Int. A specific computation of an Int might result
in several, or zero, actual Ints (the list monad); a String or an Int (the
Either String monad); the constant () (the trivial monad); ...
The type Monad m => m Int cannot represent multiple computations of an
Int. The type Monad m => [m Int] represents multiple computations of an
Int (of course, any container type can be used in place of list).
-Jeff
---
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070814/0e28fd70/attachment-0001.htm
More information about the Haskell-Cafe
mailing list