[Haskell-cafe] Reader monad

michael rice nowgate at yahoo.com
Wed Dec 29 18:50:51 CET 2010

I think of (r -> m a) as a type signature and Int or Bool by themselves as types. So, all type signatures are themselves types?


--- On Wed, 12/29/10, Henning Thielemann <lemming at henning-thielemann.de> wrote:

From: Henning Thielemann <lemming at henning-thielemann.de>
Subject: Re: [Haskell-cafe] Reader monad
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org
Date: Wednesday, December 29, 2010, 12:28 PM

On Wed, 29 Dec 2010, michael rice wrote:

> In the case of ReaderT and StateT
> newtype ReaderT r m a = ReaderT {
>         -- | The underlying computation, as a function of the environment.
>         runReaderT :: r -> m a
>     }
> newtype StateT s m a = StateT { runStateT :: s -> m (a, s) }
> what is the existing type?

The existing type is 'r -> m a'. You could also write

> newtype ReaderT r m a = ReaderT (r -> m a)

This would be the same type as above, but it would have no accessor function 'runReaderT'.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101229/bcb63e6d/attachment.htm>

More information about the Haskell-Cafe mailing list