[Haskell-cafe] Are explicit exports and local imports desirable in a production application?

Evan Laforge qdunkan at gmail.com
Mon Sep 21 00:27:20 UTC 2020


On Fri, Sep 18, 2020 at 12:48 AM Simon Peyton Jones
<simonpj at microsoft.com> wrote:
>
> |  For explicit exports, I often leave them off for convenience during
> |  development, but put them in when it settles down.  I don't think it
> |  unlocks any optimization in code generation
>
> Actually, it does make a difference to optimisation.  If a function is known not to be exported, then GHC knows every one of its call sites.  Eg so

I stand corrected!

I recall reading somewhere that, for the purposes of inlining, all
symbols inside the module are fully visible, so the only difference
the export makes is whether or not the non-inlined/specialized version
is also kept around for possible external callers.  So maybe that's
just wrong, or I made it up somehow, or maybe it's right but just for
inlining and not for those other things?

I suppose it could theoretically have been right if GHC were willing
to duplicate all exported functions and perhaps analyze them twice,
but perhaps it's not willing to do that?  I'm not saying it should,
especially if it would hurt compile time, just curious.


More information about the Haskell-Cafe mailing list