Hello,
> On 8/14/07, Jeff Polakow <jeff.polakow@db.com> wrote:
> > One general intuition about monads is that they represent computations
> > rather than simple (already computed) values:
>
> > x :: Int
-- x is an Int
> > x :: Monad m => m Int -- x is a computation
of an Int
>
> What's a "computation"? It seems to me that in a lazy language,
x::Int
> represents a computation of an int, not an "already computed"
value.
>
This intuition for monads as "computations"
is independent of operational semantics.
> x::[Int] is a computation that returns multiple
values. x::(Int,Int)
> is a computation that returns a pair of values. x::() is a computation
> that returns nothing. x::Map a b is a computation that gives a way
to
> associate values of type a with values of type b. Some of these are
> monads, some are not. What's the difference between them? Why are
you
> calling certain values "computations"?
>
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. However, I do not mean to imply that everything which can be viewed
as a computation of something is a monad.
In any case, this is only meant to be a general (i.e.
high-level) intuition. BTW, this intuition was, more or less, the one used
by Moggi when describing how monads can be used to describe denotational
models for languages.
-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.