Ticket #3670 (closed feature request: fixed)
Allow RULES for higher-ranked terms
Description
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 #-}
Change History
Note: See
TracTickets for help on using
tickets.
