| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
ReWire.Eidos.Externs
Description
Extern neutering (the retired Crust pass's successor).
Decides, per extern, whether the user-supplied Haskell implementation
(rwPrimExtern's seventh argument) can serve as a model for the
interpreter, and replaces it with an inert error placeholder
otherwise, so the simplifier never descends into extern
implementations. An implementation is kept only when it is a
reference to a top-level definition — other than the extern's own
enclosing definition, since f = extern "f" f is the conventional
no-model idiom — whose reachable definitions are all non-recursive
and representable. Implementations that look like real models but
fail the checks are neutered with a warning.
Cryptol foreign functions (rwPrimCryptol's third argument, the GHC-side implementation) are neutered unconditionally and silently: their meaning is the Cryptol source, compiled to an ordinary definition by the fold, so there is never a model to keep — only the argument's type survives (the fold reads the use-site monotype off the placeholder).
After INLINE inlining, an extern application is still wrapped in the beta redexes left by inlining the extern/externWithSig wrappers, so definitions containing externs are reduced first to expose the implementation argument. (On Eidos this needs no isolated freshness counter: the pass's supply is seeded above the program and perturbs nothing else.) This pass must run before the simplifier.
Synopsis
- neuterExterns :: MonadError AstError m => Program -> m (Program, [Warning])
Documentation
neuterExterns :: MonadError AstError m => Program -> m (Program, [Warning]) Source #
Returns the neutered program and the warnings for discarded models (emitted by the caller, which holds the Config).