Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Haskell-cafe] type error using ghc 6.10.1, not in previous versions

2 views
Skip to first unread message

Tim Bauer

unread,
Jan 12, 2009, 10:14:56 PM1/12/09
to haskel...@haskell.org
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)
import Control.Concurrent
import Control.Exception(catch,throw,evaluate)

async :: IO a -> IO (MVar a)
async ioa = do
mVar <- newEmptyMVar
forkIO $ catch (ioa >>= putMVar mVar) (putMVar mVar . throw)
return mVar


Under 6.10. I now get a type error.

TypeError.hs:13:55:
Ambiguous type variable `e' in the constraint:
`GHC.Exception.Exception e'
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?
Thanks,
- Tim
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Anish Muttreja

unread,
Jan 13, 2009, 1:57:12 AM1/13/09
to Tim Bauer, haskel...@haskell.org

Hi Tim,
There were messages about this on the list before, I believe.
>From ghc 6.10.1 release notes, what changed is this
"Control.Exception now uses extensible exceptions. The old style of
exceptions are still available in Control.OldException, but we expect to
remove them in a future release. "
http://www.haskell.org/ghc/docs/6.10.1/html/users_guide/release-6-10-1.html

Providing a type signature for the argument of throw ought to fix it.
forkIO $ catch (ioa >>= putMVar mVar) (\e -> (putMVar mVar . throw) (e
:: IOException) )

I don't really understand what extensible exceptions are, just
that providing a type signature makes the compiler happy. This
www.haskell.org/~simonmar/papers/ext-exceptions.pdf might provide the
explanation.

Hope that helps.

Anish

0 new messages