Hello!
I'm confused by the error handling in Haskell. I've written a program that
uses a combined monad of type:
type MyMonad a = ErrorT MyErrorType (StateT MyStateType IO) a
(MyErrorType is an instance of Error)
Therefore, to handle IO Errors inside of MyMonad I need to write:
foo :: MyMonad a
foo = do ...
inp <- liftIO (getChar
`catchError`
(\e -> if isEOFError e then return '\0'
else return
'?') )
case inp of
'\?' -> throwError ...
....
`catchError`
myErrorTypeHandler
This of course is cumbersome and ugly and I'm sure there is a way to do
better. Helpful advice is welcome!
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/