Proposal: EPHEMERAL pragma

José Pedro Magalhães jpm at
Thu Oct 25 15:56:48 CEST 2012

Hi all,

Following up on a chat with Simon Peyton Jones at ICFP, I would like to
discuss the
possible introduction of a EPHEMERAL pragma. For example:

{-# EPHEMERAL Rep #-}
> data Rep = ...

This pragma would indicate that the programmer intends the Rep datatype not
be present in the final generated core code. Its proposed semantics are the

1. Make the compiler very keen to inline any functions that produce or
consume Rep.

2. If Rep is exported, make all functions that operate on Rep INLINABLE
(that is, make
their code available for inlining in other modules).

3. Emit a warning if the generated core code still contains uses of Rep.

My main use case for such a pragma is in the generic representation of
datatypes in
GHC.Generics. It's clear that we don't want sums and products lying around
in user
code, and in most cases we can get rid of them by inlining aggressively.
such a pragma can simplify or entirely replace the use of INLINE/INLINABLE
in some cases.

However, I'm not sure how well this can work in practice. Regarding (3),
for instance,
it's clear that functions that operate on Rep will be around in the final
core code;
perhaps only functions which do not directly produce or consume Rep, yet
end up
having values of Rep within them, should trigger a warning.

(1) is hard to do well, in general. In particular when there are rewriting
rules involving
values of Rep, or functions that produce/consume Rep, the order in which
they are
inlined might affect the elimination of Rep values.

In any case, I thought I'd share this with this list, in the hope to get
feedback regarding
how to improve the inliner (and the feedback programmers get regarding

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Glasgow-haskell-users mailing list