IOError

Wolfgang Jeltsch wolfgang@jeltsch.net
Thu, 12 Jun 2003 21:19:07 +0200


On Thursday, 2003-06-12, 21:02, CEST, Dean Herington wrote:
> On Thu, 12 Jun 2003, Wolfgang Jeltsch wrote:
> > [...] 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>
>
> Beware: The above causes pattern match failure if a true error (other than
> end of file) occurs.  You probably want something like:
>
>     case t of
>         Left error | isEOFError error
>             -> do <EOF handling>
>                    | otherwise
>             -> do <error handling>
>         Right result
>             -> do <normal continuation>

Ups, I overlooked this. What I really wanted was:
    case t of
        Left error
            | isEOFError error
                -> do <EOF handling>
            | otherwise
                -> ioError error
        Right result
            -> do <normal continuation>

> > [...]
>
> Dean

Wolfgang