[Haskell-beginners] Transforming (State s a) to (StateT s m a)
Yitzchak Gale
gale at sefer.org
Tue Aug 4 09:09:32 EDT 2009
Hi Toby,
Toby Murray wrote:
> Suppose I have a transformer A of type State s a...
> Suppose I have other state transformers of type StateT s m a...
> I can manually convert A to be of the second kind as follows...
> pure :: (Monad m) => State s a -> StateT s m a
> pure func = StateT (\arg -> (return (runState func arg)))
Yes, this does come up from time to time. It could be
useful to give it a standard name in the libraries.
But "pure" is not a good name - that is firmly entrenched
to mean other important things in Control.Applicative
and Control.Arrow.
Perhaps liftT?
liftT :: (Monad m) => State s a -> StateT s m a
liftT (State f) = StateT $ return . f
You can submit your proposal by following this
procedure:
http://www.haskell.org/haskellwiki/Library_submissions
Regards,
Yitz
More information about the Beginners
mailing list