- -- Common special case: no type or dictionary abstraction
- -- For the (rare) case when there are some mixed-up
- -- dictionary bindings (for which a Rec is convenient)
- -- we reply on the enclosing dsBind to wrap a Rec around.
+-- Note [Rules and inlining]
+-- Common special case: no type or dictionary abstraction
+-- This is a bit less trivial than you might suppose
+-- The naive way woudl be to desguar to something like
+-- f_lcl = ...f_lcl... -- The "binds" from AbsBinds
+-- M.f = f_lcl -- Generated from "exports"
+-- But we don't want that, because if M.f isn't exported,
+-- it'll be inlined unconditionally at every call site (its rhs is
+-- trivial). That woudl be ok unless it has RULES, which would
+-- thereby be completely lost. Bad, bad, bad.
+--
+-- Instead we want to generate
+-- M.f = ...f_lcl...
+-- f_lcl = M.f
+-- Now all is cool. The RULES are attached to M.f (by SimplCore),
+-- and f_lcl is rapidly inlined away.
+--
+-- This does not happen in the same way to polymorphic binds,
+-- because they desugar to
+-- M.f = /\a. let f_lcl = ...f_lcl... in f_lcl
+-- Although I'm a bit worried about whether full laziness might
+-- float the f_lcl binding out and then inline M.f at its call site
+