
| Something I've pondered is adding a more-expressive form of RULES which | works using general pattern matching: Yes, but it would need the rule-matcher in the Simplifier to be more sophisticated. Have a look in specialise/Rules.lhs. No need to be so ambitious; just moving towards what you can do in PrelRules would be an improvement Simon | | {-# XRULES | "*#-to-shift" (*#) | (CoreLit (CoreInt num)) obj | | num .&. (num - 1) == 0 -> | CoreApp (CoreVar "GHC.Prim.iShiftL#") | [obj, CoreLit (CoreInt (lg2 num))] | obj (CoreLit (CoreInt num)) | | num .&. (num - 1) == 0 -> | CoreApp (CoreVar "GHC.Prim.iShiftL#") | [obj, CoreLit (CoreInt (lg2 num))] | #-} | | This would require reusing the TH infrastructure, and (depending on how | much we can abstract) might leak too many details of Core to be | useful; on the other hand it would allow some very interesting domain | optimizations to be done. | | Views might be nice here. | | Opinions on whether something like this is a good idea? | | Stefan