type error using ghc 6.10.1, not in previous versions
bauertim at eecs.orst.edu
Mon Jan 12 22:14:36 EST 2009
Hi all. Under I have some old code that broke under ghc 6.10.1.
Under (6.6.1), 6.8.1 (and I think 6.8.2), this compiles.
import Prelude hiding(catch)
async :: IO a -> IO (MVar a)
async ioa = do
mVar <- newEmptyMVar
forkIO $ catch (ioa >>= putMVar mVar) (putMVar mVar . throw)
Under 6.10. I now get a type error.
Ambiguous type variable `e' in the constraint:
arising from a use of `throw' at TypeError.hs:13:55-59
Probable fix: add a type signature that fixes these type variable(s)
Prelude> :t catch
catch :: IO a -> (IOError -> IO a) -> IO a
Prelude> :t Control.Exception.catch
Control.Exception.catch :: (GHC.Exception.Exception e) =>
IO a -> (e -> IO a) -> IO a
What changed that causes this to break between 6.8 and 6.10?
In fact, I don't even see the type error (the message is
of little help). The function throw returns an `a', so it
should unify with the required type for the handler.
I tried simplifying the problematic line to:
forkIO $ catch (ioa >>= putMVar mVar) (error "boom")
(error "boom") should also unify with anything.
Can anyone suggest other things I can try and perhaps what
is going on?
More information about the Haskell-Cafe