Skip to content

Alternate syntax for indicating when a function is "fully applied" for purposes of inlining

I just remembered an old idea I put to the GHC user's list here, and thought I should present it here.

As I understand it GHC inlines inlines only after a function is fully applied with respect to the syntactic left-hand side, so in order to control inlining and sharing, we sometimes see strange things like:

{-# INLINE foo #-}
foo :: a -> b -> c
foo a = \b -> ...

It would be nice to be able to define the function syntactically in the way that's the most clear (e.g. in pointfree style, etc.) and specify at what point to inline something like this:

foo :: a -> {-# INLINE #-} b -> c
foo a b = ...
-- or:
foo = ... 
  1. ..which tells the compiler to inline after applying the arguments to the left of the pragma, and GHC would do whatever trivial (I assume?) eta-conversion was required.
Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information