[Haskell] Better Exception Handling

Lennart Augustsson lennart at augustsson.net
Thu Nov 25 14:36:41 EST 2004

Tomasz Zielonka wrote:
> On Thu, Nov 25, 2004 at 07:52:43PM +0100, Lennart Augustsson wrote:
>>As I'm sure you have gathered from all the answers you can't have the
>>latter and keep Haskell pure.  But there is an interesting alternative
>>(at least theoretically).  You could have a function like
>>mkCatchJust :: IO ((Exception -> Maybe b) -> (c -> a) -> c -> (b -> a) -> a)
> How is that different from this?
>   mkReadFile :: IO (FilePath -> String)
> This is wrong.

Why is this wrong?

> Even if I get a function as a result of an IO computation, I
> expect that function to be pure.

Yes, so do I.  The function returned will have to be pure.  Pure in the
sense that given the same argument it always has to return the same
result.  In the case of mkReadFile this is not too hard to implement.

I admit that it is rather awkward, but it can be pure.

	-- Lennart

More information about the Haskell mailing list