[Haskell-cafe] Monadic tunnelling: the art of threading one monad through another

Henning Thielemann lemming at henning-thielemann.de
Thu Jul 12 09:16:03 EDT 2007

On Wed, 11 Jul 2007, Jules Bean wrote:

> Now, supposing we have a library function which takes a callback. As
> an example, suppose we have a library function which reads in a file
> and calls our callback once on each line. A typical type might look
> like:
> forEachLine :: Handle -> (String -> IO ()) -> IO ()
> We have to provide a callback in the IO monad. But what if we don't
> want to work in the IO monad? What if we are working in, for example,
> a custom state monad of our own?

What about writing a function with signature

forEachLine :: MonadIO io => Handle -> (String -> io ()) -> IO ()


More information about the Haskell-Cafe mailing list