subtle inlining problem

Simon Peyton-Jones simonpj at microsoft.com
Wed Nov 8 12:41:51 EST 2006


| > {-# INLINE getInteger #-}
| > getInteger = ... -- large definition that will be not inlined
| >                  -- without pragma
| >
| > instance Binary Integer where
| >   get = getInteger

A simpler version is

> {-# INLINE getInteger #-}
> getInteger = ... -- large definition that will be not inlined
>                  -- without pragma
>
> get = getInteger

Here, getInteger will be inlined in the RHS of get, but GHC doesn't see any reason that 'get' should be inlined.

If you want that, add an INLINE pragma on get.

The same thing should work in an instance decl, for the same reason, but I have not tried it recently.   And, assuming it does work, it ought to be documented.  If you check, and send me draft words, I'll add them to the user manual

Simon


More information about the Glasgow-haskell-users mailing list