catch (fail "...")

Simon Peyton-Jones simonpj@microsoft.com
Fri, 22 Mar 2002 02:29:22 -0800


This is an inconsistency that was fixed in the revised Haskell98=20
report (Apr 2001).  See
	http://research.microsoft.com/~simonpj/haskell98-revised

In the bug list look for Page 90.

It looks as though Hugs hasn't quite caught up with this change.

Simon

| -----Original Message-----
| From: Brian Huffman [mailto:bhuffman@galois.com]=20
| Sent: 22 March 2002 00:22
| To: haskell@haskell.org
| Subject: catch (fail "...")
|=20
|=20
| Hi,
|=20
| Here is a problem I came across recently, revealing a=20
| difference between ghci=20
| and Hugs:
|=20
| hugs> catch (error "not ok") (\e -> putStrLn "ok")
| Program error: not ok
| ghci> catch (error "not ok") (\e -> putStrLn "ok")
| *** Exception: not ok
|=20
| hugs> catch (ioError (userError "not ok")) (\e -> putStrLn "ok")
| ok
| ghci> catch (ioError (userError "not ok")) (\e -> putStrLn "ok")
| ok
|=20
| hugs> catch (fail "not ok") (\e -> putStrLn "ok")
| Program error: not ok
| ghci> catch (fail "not ok") (\e -> putStrLn "ok")
| ok
|=20
| As I expected, neither of them can catch "error", and both of=20
| them can catch=20
| "ioError". But only ghci can catch the "fail". It seems to me=20
| that ghc has=20
| made a convenient choice here, because if I need to raise an=20
| IO exception, it=20
| is easier to type "fail s" than "ioError (userError s)".
|=20
| However, the online Haskell report says that for IO, fail=A0s=A0=3D=A0
| error=A0s, which=20
| is what Hugs does.=20
| (http://www.haskell.org/onlinereport/standard-prelude.html#$iM
onad$$IO)

Does anyone know the reasoning behind the design choice made in the =
report,=20
or why the ghc implementation is different? I am mainly concerned about=20
portability issues: particularly, is it a good idea to use fail for =
raising=20
IO exceptions?

Thanks
- Brian Huffman
_______________________________________________
Haskell mailing list
Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell