[Haskell-beginners] ghc-6.10.3 IOException?

Daniel Fischer daniel.is.fischer at web.de
Sun Jun 14 19:19:57 EDT 2009


Am Montag 15 Juni 2009 00:29:27 schrieb Erik de Castro Lopo:
> Daniel Fischer wrote:
> > Simple solution:
> > import Control.OldException instead of Control.Exception
>
> I actually already had that working :-).

D'oh

>
> > Harder long-time solution:
> > rewrite the code to work with the new system.
>
> This is what I'd like to do. Is there a guide or howto for converting
> from OldException to Exception?

I don't know of one.

You could use the SomeException type and have

handler e = case fromException e of
               Just e' | isEOFError e' -> return ()
               _ -> print e

or you could only handle IOExceptions,

handler e
    | isEOFError e = return ()
    | otherwise = print e

either way, you must somehow determine which type of exception "throwTo mainTID" in spawn 
throws, in the first case its type would be (SomeException -> IO ()), in the second 
(IOException -> IO ()).
For the first case, it would probably better to have

act `catch` (throwTo mainTID . toException)

in spawn.

>
> > then see whether it's worth the rewrite.
>
> As a learning exercise I thin it is :-).

I agree.

>
> Erik



More information about the Beginners mailing list