[Haskell-cafe] rewrite rules to specialize function according to type class?

Roman Leshchinskiy rl at cse.unsw.edu.au
Tue Feb 15 17:45:28 CET 2011

Max Bolingbroke wrote:
> On 15 February 2011 15:12, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
>> Ah, but you assume that bar won't be inlined into foo first. Consider
>> that it is perfectly acceptable for GHC to generate this:
>> foo = <big> {-# INLINE bar #-}
>> bar = <big>
>> We did ask to inline bar, after all.
> Well, yes, but when considering the use site for foo don't we now
> inline the *original RHS* of foo? This recent change means that it doesn't
> matter whether bar gets inlined into foo first - use sites of foo will
> only get a chance to inline the "bar" RHS.

Only if foo has an INLINE pragma. Otherwise, GHC uses whatever RHS is
available when it wants to inline.


More information about the Haskell-Cafe mailing list