Prelude.catch vs. Exception.catch
Ashley Yakeley
ashley@semantic.org
Tue, 14 May 2002 01:41:06 -0700
--Emailer_-1190570758
Content-Type: text/plain; charset="US-ASCII"
At 2002-05-13 22:07, Ashley Yakeley wrote:
>I've noticed something a bit unusual about Exception.catch.
Curiously, the definition of Exception.evaluate given in the GHC
Libraries documentation sec. 5.12.3 is not that actually implemented by
GHC.
evaluate' :: a -> IO a;
evaluate' a = a `seq` return a;
"evaluate' undefined" is bottom, whereas "Expression.evaluate undefined"
is an IO action that "fails" when executed. But both will be caught by
Exception.catch.
--
Ashley Yakeley, Seattle WA
--Emailer_-1190570758
Content-Type: text/plain; name="TestException.hs";
x-mac-type="54455854";
x-mac-creator="522A6368"
Content-transfer-encoding: base64
Content-Disposition: Attachment; filename="TestException.hs"
LS0gZ2hjIC1wYWNrYWdlIGxhbmcgVGVzdEV4Y2VwdGlvbi5ocyAtbyBUZXN0RXhjZXB0aW9uCm1v
ZHVsZSBNYWluIHdoZXJlCgl7CglpbXBvcnQgSU9SZWY7CglpbXBvcnQgcXVhbGlmaWVkIEV4Y2Vw
dGlvbjsKCglnZXRQdXJlRXhjZXB0aW9uIDo6IGEgLT4gSU8gKE1heWJlIEV4Y2VwdGlvbi5FeGNl
cHRpb24pOwoJZ2V0UHVyZUV4Y2VwdGlvbiBhID0gKEV4Y2VwdGlvbi5jYXRjaCAoc2VxIGEgKHJl
dHVybiBOb3RoaW5nKSkgKHJldHVybiAuIEp1c3QpKTsKCglzaG93SU9TIDo6IFN0cmluZyAtPiBJ
TyBTdHJpbmcgLT4gSU8gKCk7CglzaG93SU9TIHMgaW9zID0gZG8KCQl7CgkJcHV0U3RyIChzICsr
ICI6CSIpOwoJCW1wZSA8LSBnZXRQdXJlRXhjZXB0aW9uIGlvczsKCQljYXNlIG1wZSBvZgoJCQl7
CgkJCUp1c3QgcGUgLT4gcHV0U3RyTG4gKCJwdXJlIGV4Y2VwdGlvbiAoIisrIChzaG93IHBlKSAr
KyIpIik7CgkJCU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