[Haskell-cafe] Monad explanation

Lennart Augustsson lennart at augustsson.net
Mon Feb 9 05:32:22 EST 2009

But an (IO Char) is a value.  You can do all the things with it that
you can do with values, e.g., pass it as an argument, stick it in a
list, etc.  It is a special kind of value, since if it ever "gets in
contact with" the top level it will be executed.
But the fact that IO types also behave as values makes Haskell a very
powerful imperative language.

On Mon, Feb 9, 2009 at 11:14 AM, Tony Morris <tmorris at tmorris.net> wrote:
> Hash: SHA1
> You're right - my statement is inaccurate.
> Implementation details aside, I am referring specifically to the
> statement "getChar ... has the type signature of a value". It clearly
> does not.
> Lennart Augustsson wrote:
>> Not it doesn't.  getChar has the type signature IO Char. The IO
>> type is abstract.  GHC happens to implement it by a state monad.
>> But in, e.g., hbc it is implemented in a totally different way,
>> more like a continuation monad.
>> Peeking inside an implementation of IO can be illuminating, but one
>> must remember that IO is abstract.
>> -- Lennart
>> On Mon, Feb 9, 2009 at 10:26 AM, Tony Morris <tmorris at tmorris.net>
>> wrote: Gregg Reynolds wrote:
>>>>> The point being that the metalanguage commonly used to
>>>>> describe IO in Haskell contains a logical contradiction.  A
>>>>> thing cannot be both a value and a function, but e,g, getChar
>>>>> behaves like a function and has the type signature of a
>>>>> value.
>> getChar has the signature RealWorld -> (RealWorld, Char)
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> - --
> Tony Morris
> http://tmorris.net/
> S, K and I ought to be enough for anybody.
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> iEYEARECAAYFAkmQAfkACgkQmnpgrYe6r61tmQCcCx42Cz1iunkD7JGubla/z2Pg
> uhAAoLk5rkjeHnrfc936IhYoBQYO/+0r
> =6xWk

More information about the Haskell-Cafe mailing list