IO Errors

Sigbjorn Finne sof@galconn.com
Tue, 29 May 2001 00:32:08 -0700


Dominic J Steinitz Dominic.J.Steinitz@BritishAirways.com writes:
> 
> Can anyone tell me why this behaves as it does? In Hugs, I get 
> 
> C:\My Documents\functional\ldapsck1\buffer.hs
> Main> main
> 
> Illegal operation
> (561 reductions, 1029 cells)
> 
  ..program elided...
> 

The reason for the behaviour you're seeing is that Hugs doesn't report
you reading past the end of the file as an EOF error (Hugs never
reports EOF errors, but maps them to illegal ops instead). So, to have
it work with both Hugs and GHC, you need to change the 'Left' branch
of the case expression in 'main' from

  Left e ->
     if isEOFError e 
                             then do ....
                             else do ...

to

  Left e ->
     if isEOFError e || isIllegalOperation e
                             then do ....
                             else do ...


hth
--sigbjorn