Andres Löh, Edsko de Vries
Wednesday, 16 April 2025
In January, we presented our work on Explicit Level Imports at the Trends in Functional Programming symposium. We’re pleased to announce that the paper was awarded the the John McCarthy Prize for best paper overall!
The paper introduces the ExplicitLevelImports
extension to GHC, which gives
programmers fine-grained control over which modules and dependencies are
required by Template Haskell. For instance, in the following example, the
splice
import tells the compiler that Control.Lens.TH
is needed only at compile
time and not at runtime:
import splice Control.Lens.TH (makeLenses)
import App (S)
data T = MkT { foo :: S }
$(makeLenses ''T )
By taking advantage of this extra information, the compiler can perform less work
in certain situations. In one benchmark, we modified pandoc
to use ExplicitLevelImports
and
compilation time was halved when using -fno-code
. For full details, read the paper
or check out
GHC Proposal #682.
The implementation has landed in
GHC MR !14241,
so ExplicitLevelImports
will be available in the next major release of GHC (9.14).