[Haskell-cafe] Principal type in Haskell

Gerrit van den Geest g.vandengeest at students.uu.nl
Thu Jun 22 05:33:21 EDT 2006

According to Haskell 98 the principal type of f should be:

f :: (Eq a) => a -> a -> Bool.

GHC does only perform context-reduction using instance-declarations if 
there are no type-variables in the type. Because the type in this 
function is [a], ghc doesn't perform context-reduction. Ghc chooses this 
strategy because of extensions like overlapping instances, there remains 
more information in the type of a function to select an instance.

For some reason GHC also applies this strategy if one turns of the 


william kim wrote:

> Hi All,
> I am confused by the notion of principal type in Haskell with type 
> classes. Consider a simple example:
> f x y = [x] == [y]
> GHCi yields type f :: (Eq [a]) => a -> a -> Bool.
> But according to the paper "Type classes: an exploration of the design 
> space", predicate Eq [a] should be reduced to Eq a. Is this reduction 
> performed here? What should be the principal type of f?
> Thanks.
> william
> _________________________________________________________________
> Get an advanced look at the new version of MSN Messenger. 
> http://messenger.msn.com.sg/Beta/Default.aspx
> _______________________________________________
> 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