Skip to content

BuiltinRules override other rules in some cases.

It seems that the Class op * rules will override a user defined rule for class functions.

This seems to be a long outstanding issue: http://stackoverflow.com/questions/9811294/rewrite-rules-not-firing-for-rules-matching-multiple-instance-methods

I also just ran into someone else on the haskell IRC channel who had an even simpler example then the one on that page:

{-# NOINLINE d #-}
{-# RULES "d exp" d exp = exp #-}
d :: (Double -> Double) -> (Double -> Double)
d f = f . (+20.0)

g :: Double -> Double
g = (+5.0)

main = do
  print $ d exp 1.0     -- FAIL should print 2.718281828459045  >>  printed exp 21.0 instead
  print $ d g 3.0       -- PASS should print 28.0

-- Compiled with:
--   ghc -fenable-rewrite-rules -O rules.hs
Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information