[Haskell-cafe] MonadTrans lift implementation
Mauro J. Jaskelioff
mjj at Cs.Nott.AC.UK
Tue Jan 20 13:33:33 EST 2009
Ross Paterson wrote:
> On Mon, Jan 19, 2009 at 01:13:37PM -0800, Jonathan Cast wrote:
>> (On the other hand, your hunch that lift = return is correct --- so you
>> get a cookie for that; it's just that return here is neither the return
>> of the monad for m nor the return of the monad for ReaderT m. It is,
>> instead, the return of the *applicative functor* --- on the category of
>> monads and monad homomorphisms --- associated to the monad transformer
> It's also a monad in the category of monads, as are ErrorT, StateT and
> WriteT (see Moggi, An Abstract View of Programming Languages, 1989, s4).
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Monads in the (2-)category of monads correspond to distributive laws
(see Formal theory of Monads by Street, 1972).
StateT does not arise from a distributive law.
In particular, you would need a map
tjoin :: Monad m => StateT (StateT m) a -> StateT m a
:: Monad m = (s -> s -> m ((a,s),s)) -> s -> m (a,s)
subject to the monad laws (where
lift :: Monad m => m a -> StateT m a
is the unit, i.e. return)
All the best
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
More information about the Haskell-Cafe