#3670: Allow RULES for higher-ranked terms
-----------------------------+----------------------------------------------
Reporter:  rl                |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Compiler        
 Version:  6.13              |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 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
 #-}
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3670>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to