Hi, Ryan. Since I'm trying to understand Reader, I wanted to be aware of all cases of Reader.
========== >From the docs (and tuts) newtype creates a new type out of an existing type and gives a single constructor for doing so. From: http://www.haskell.org/tutorial/moretypes.html newtype Natural = MakeNatural Integer This creates an entirely new type, Natural, whose only constructor contains a single Integer. The constructor MakeNatural converts between an Natural and an Integer: toNatural :: Integer -> Natural toNatural x | x < 0 = error "Can't create negative naturals!" | otherwise = MakeNatural x fromNatural :: Natural -> Integer fromNatural (MakeNatural i) = i In the above case the existing type is Integer. The new type behaves like the existing type, but we can pattern match with the new type. ++++++++++ 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? Michael --- On Wed, 12/29/10, Ryan Ingram <[email protected]> wrote: From: Ryan Ingram <[email protected]> Subject: Re: [Haskell-cafe] Reader monad To: "michael rice" <[email protected]> Cc: [email protected] Date: Wednesday, December 29, 2010, 11:11 AM On Wed, Dec 29, 2010 at 8:06 AM, michael rice <[email protected]> wrote: > Is there an unparameterizable reader monad? I'm not sure this is the answer you are looking for, but it seems like the obvious one. Pick an "r", say "String". Now "Reader String" is an unparameterizable reader monad that passes around a String. -- ryan
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
