Constraint order must match with RankNTypes
In the following code, GHC will not compile unless the constraints on the higher-rank function have the same *order* as the method declaration in ApPair
.
{-# LANGUAGE RankNTypes #-}
class ApPair r where
apPair ::
(forall a . (ApPair a, Num a) => Maybe a)
-> Maybe r
instance (ApPair a, ApPair b)
=> ApPair (a,b) where
apPair = apPair'
apPair' :: (ApPair b, ApPair c)
=> (forall a . (ApPair a, Num a) => Maybe a) -> Maybe (b,c)
apPair' f =
let (Just a) = apPair f
(Just b) = apPair f
in Just $ (a, b)
That is, the following does *not* compile:
apPair' :: (ApPair b, ApPair c)
=> (forall a . (Num a, ApPair a) => Maybe a) -> Maybe (b,c)
apPair' f =
let (Just a) = apPair f
(Just b) = apPair f
in Just $ (a, b)
GHC probably shouldn't care about lexical matching when checking constraints.
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.4 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |