Hi!

I'm trying to use the catch function in the Exception library in hslibs.
But I can't even get my programs to compile. It feels like this is a
silly mistake on my side but I'll ask anyway. I've boiled it down to the
following program:

> module Main where
>
> import Prelude hiding (catch)
> import Exception
> import IO hiding (catch)
>
> main = do let f = "file"
>           catch (openFile f ReadMode >> return ())
>                 (\e -> hPutStr stderr ("Couldn't open "++f++": " ++ show e))

This is basically the example program from the documentation of
Exception.catch (corrected so that it is type correct). If I compile this
program ghc gives me:

    Couldn't match `(->) Exception' against `IO'
        Expected type: Exception -> a
        Inferred type: IO Handle
    Probable cause: `openFile' is applied to too many arguments in the
call
        (openFile f ReadMode)
    In the first argument of `>>', namely `openFile f ReadMode'

However, if I hide catch from Exception and use the IO version instead
then the program compiles fine. But according to the documentation the
types of IO.catch and Exception.catch are the same. Are they?

I'm using:
The Glorious Glasgow Haskell Compilation System, version 4.08.1

        /Josef


_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to