[Haskell-cafe] Gentle introduction questions / comments

Matthijs Kooijman matthijs at stdin.nl
Tue Jan 27 07:41:18 EST 2009

Hi all,

I've been reading the gentle introduction to Haskell a bit more closely today
and there a few things which I can't quite understand (presumably because they
are typo's). I've found two issues with the "Using monads" section [1]. Not
sure if this is the right place to report this, but there's probably somewhere
here who can fix it :-)

The first one is in the state monad data type. It reads:

	data SM a = SM (S -> (a,S))  -- The monadic type

I  can't seem to find out what "S" is exactly here. It seems to be a
universally quantified type variable, but then it should be lowercase.
Considering that it is referred to later on as "s", I suspect this is a type?

Further on, a resource monad is described. Here, a lift1 function is given
to allow one to lift a normal computation into a resource aware computation,
with the following type signature:

	lift1                   :: (a -> b) -> (R a -> R b)

A few lines down, the inc operation is defined as follows:

	inc i                   =  lift1 (i+1)

To me, this seems wrong. Even without going into the semantics, it seems that
the (i+1) expression does not satisfy the type of the first argument to lift1.
I suspect this should have been:

	inc                     = lift1 (+1)



[1]: http://www.haskell.org/tutorial/monads.html#sect9.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090127/0855777e/attachment.bin

More information about the Haskell-Cafe mailing list