inlining higher-order-functions?
Simon Peyton-Jones
simonpj at microsoft.com
Fri Dec 22 03:29:52 EST 2006
| My example is complicated, so let me present a simpler analogy.
| Suppose I defined
|
| compose :: (b -> c) -> (a -> b) -> (a -> c)
| compose f g = \x -> f (g x)
|
| I can easily persuade GHC to inline 'compose'.
| But when 'compose' is applied to known arguments, I wish
| f and g to be inlined in the body of 'compose'.
| Is there a pragma that will do the trick?
| (I attempted to put an INLINE pragma in a where clause,
| but GHC was not amused.)
You can put inline pragmas on f and g, thus
frob = ...
{-# INLINE frob #-}
burk = ...
{-# INLINE burk #-}
wibble = compose from burk
Now compose will be inlined (assuming it too has an INLINE pragma), and then frob, burk.
Simon
More information about the Glasgow-haskell-users
mailing list