On Sun, May 08, 2005 at 07:54:43PM +0400, Max Vasin wrote:
> Hello!
> 
> Suppose we have functions 
> 
> f :: ReaderT env monad1 rtype
> g :: Reader env rtype
> 
> and we need to call g from f.
> 
> Currently I write something like
> 
> f = do env <- ask
>        let r = runReader g env
>        doSmth r
> 
> I don't like doing it this way (I need to get environment and
> explicitly pass it). Is there another way to get things done?

How about:

    toReaderT :: (Monad m) => Reader r a -> ReaderT r m a
    toReaderT (Reader f) = ReaderT (return . f)

Best regards
Tomasz
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to