[Haskell-cafe] Re: How to combine Error and IO monads?

John Goerzen jgoerzen at complete.org
Tue Dec 12 23:54:28 EST 2006


On Fri, 08 Dec 2006 07:31:25 -0500, Cat Dancer wrote:

> On 12/7/06, J. Garrett Morris <trevion at gmail.com> wrote:
>>
>> foo :: ErrorT String IO Int
>>
>> Since ErrorT String IO Int is not the same as IO, you can't use IO
>> operations directly.  In this case, you want:
>>
>> <     a <- lift getLine
>>
>> You want:
>>
>> <     r <- runErrorT foo
>>
> 
> Wow!  I found your help terrific!  Thank you!   Can I give you some money?

I didn't see the original question, but there are some examples of this in
the ConfigFile (formerly part of MissingH) docs here:

http://software.complete.org/configfile/static/doc/Data-ConfigFile.html#12

After you read that, you'll probably also want to scroll back and look at
the other examples of usage:

http://software.complete.org/configfile/static/doc/Data-ConfigFile.html#9

to really give you a complete sense of the styles available.

The Error monad is one of the really awesome things about Haskell, IMHO.

-- John



More information about the Haskell-Cafe mailing list