
Neil Mitchell wrote:
Hi,
A pattern match failure in a "do" will call "fail" (not "error" as other pattern match failures do). This is the "fail" of the IO monad, which calls "ioError".
I believe according to Haskell 98, fail in the IO monad calls error - its only recent extension to GHC/Hugs which have resulted in ioError and exceptions. Perhaps for the purposes of hat stuff, error should be called instead? At least until a proper exception story can be developed.
From the Haskell 98 report: The fail method of the IO instance of the Monad class (Section 6.3.6 http://haskell.org/onlinereport/basic.html#monad-class) raises a userError, thus: instance Monad IO where ...bindings for return, (>>=), (>>) fail s = ioError (userError s) Also other IO operations (e.g. file not found) will directly raise an exception. Ciao, Olaf