IOError

Wolfgang Jeltsch wolfgang@jeltsch.net
Thu, 12 Jun 2003 18:17:50 +0200


On Thursday, 2003-06-12, 18:01, CEST, Filip wrote:
> Hi,
>
> I wrote something like "let t = try (hGetLine h1)" and I would like to check
> is it EOFError or not. How can I do this ??
>
> Thanks

Hello,

the above code assigns the I/O action
    try (hGetLine h1)
to t. I suppose you want to assign the result of this action to t. If this is 
the case, you have to write
    t <- try (hGetLine h1).
You can then examine t as in the following example:
    t <- try (hGetLine h1)
    case t of
        Left error | isEOFError error
            -> do <EOF handling>
        Right result
            -> do <normal continuation>
A better way might be to use catch which is exported from the Prelude.

Wolfgang