[Haskell-cafe] type error using ghc 6.10.1, not in previous
versions
Anish Muttreja
anishmuttreja at gmail.com
Tue Jan 13 01:56:43 EST 2009
On Mon, Jan 12, 2009 at 07:14:36PM -0800, Tim Bauer wrote:
> 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.
>
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
> 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
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list