Allow RULES for higher-ranked terms
Here is a small code sample:
foo :: (forall m. m a -> m b) -> m a -> m b
foo f = f
bar :: (forall m. m a -> m a) -> m a -> m a
bar f = f
I'd like to specialise foo
to bar
whenever possible but there seems to be no way of doing so. This doesn't work:
{-# RULES "foo/bar" foo = bar #-}
GHC complains:
Cannot match a monotype with `(forall (m1 :: * -> *). m1 a -> m1 b)
-> m a
-> m b'
Adding a signature to the rhs of the rule doesn't help. GHC doesn't accept signatures in the lhs. The following works, of course, but it's not as general:
{-# RULES "foo/bar" forall (f :: (forall m. m a -> m a)). foo f = bar f #-}
Trac metadata
Trac field | Value |
---|---|
Version | 6.13 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |