[Haskell-cafe] Confused about AllowAmbiguousTypes

Audun Skaugen audunskaugen at gmail.com
Thu Sep 18 15:00:45 UTC 2014


I am confused about the behaviour of the AllowAmbiguousTypes extension. I  
tried the basic example of the user manual:

> class C a where
> f :: C a => Int
> f = 3
> main = print f

Using ghc 7.8.3, without the extension, this will cause a type error at  
the type signature (line 2). Adding AllowAmbgiuousTypes causes an error at  
the call site instead (line 4). So far so good.

However, if I replace the (C a) constraint with (Num a), no type error is  
reported, and the example runs fine! This is true with or without the  
extension. Using ghc 7.6.3, however, the example is still rejected with an  
"ambiguous constraint" error.

Is this a bug in ghc 7.8? Is ghc somehow able to prove the Num constraint  
even though a is universally quantified?

-- 
Audun Skaugen


More information about the Haskell-Cafe mailing list