As far as I can tell from the manual, nothing’s stopping me from writing some fusion-y rewrite rules for some base
functions in one of my own modules, and any consumers of that module get my rewrite rules (which is what I want; it enables more inlining). This intuitively seems like shaky ground, but I haven’t found any advice for or against the technique. Who’s got opinions?
(The rules in question, if anyone has any feedback on them for me:)
{-# RULES
"foldrMap1/build"
forall f k x (g :: forall b. (a -> b -> b) -> b -> b).
foldrMap1 f k (x :| build g) =
g (\y f' z -> k z (f' y)) f x
"foldrMap1/augment"
forall f k x xs (g :: forall b. (a -> b -> b) -> b -> b).
foldrMap1 f k (x :| augment g xs) =
g (\y f' z -> k z (f' y)) (foldr (\y f' z -> k z (f' y)) f xs) x
#-}