On Sat, Feb 21, 2009 at 5:37 PM, David Menendez <d...@zednenem.com> wrote: > > PS. Here are two functions that I ended up not using in my examples, > but which may come in handy when dealing with nested applications of > StateT: > > curryStateT :: (Monad m) => StateT (s,t) m a -> StateT s (StateT t m) a > curryStateT m = StateT $ \s -> StateT $ \t -> > runStateT m (s,t) >>= \ ~(a,(s,t)) -> return ((a,s),t) > > uncurryStateT :: (Monad m) => StateT s (StateT t m) a -> StateT (s,t) m a > uncurryStateT m = StateT $ \ ~(s,t) -> > runStateT (runStateT m s) t >>= \ ~((a,s),t) -> return (a,(s,t)) >
For some reason that reminds me of one of my favorites: embedReader :: Monad m => ReaderT r m a -> Reader r (m a) embedReader m = Reader $ \r -> runReaderT m r Antoine _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe