| Safe Haskell | Trustworthy |
|---|---|
| Language | Haskell2010 |
ReWire.GHC.Recognize
Description
Recognition for the Core-to-Eidos bridge: classifying GHC names and types (primitives, the RWC.Primitives mirror module, user classes, erasable evidence), the external tycon and base-vocabulary tables, naming conventions for Vars and constructors, and source locations. Everything here answers "what is this Core thing to ReWire?"; the translation itself lives in ReWire.GHC.ToEidos.
Synopsis
- uKey :: Var -> Int
- spanAnnote :: SrcSpan -> Annote
- varAnnote :: Var -> Annote
- isPrimModule :: ModuleName -> Bool
- isPrimVar :: Var -> Bool
- homeishMod :: Maybe ModuleName -> Bool
- qualName :: ModuleName -> Var -> Text
- conName :: DataCon -> Text
- tupleName :: Int -> Text
- splitStart :: Text -> (String, String)
- localOcc :: Var -> Text
- erasedArg :: CoreExpr -> Bool
- erasedEv :: Type -> Bool
- userPred :: Type -> Bool
- tyConModule :: TyCon -> Maybe ModuleName
- tyConKey :: TyCon -> (String, String)
- tyConTable :: [((String, String), (Text, Int))]
- vocabTable :: [(Text, [(Text, Text)])]
- maybeTyName :: Text
- eitherTyName :: Text
Documentation
IntMap key for a binder (uniques are 64-bit as of GHC 9.10; low bits suffice as map keys within one compilation).
spanAnnote :: SrcSpan -> Annote Source #
isPrimModule :: ModuleName -> Bool Source #
In the RWC.Primitives module (the GHC-visible mirror of PrimBasis), type and constructor names map to their bare occurrence names.
homeishMod :: Maybe ModuleName -> Bool Source #
Home modules (loaded from source) get qualified names; known external entities are in the tables; anything else external is out of vocabulary. There is no unit map here, so approximate: well-known external namespace prefixes are rejected, everything else is assumed to be a home module.
splitStart :: Text -> (String, String) Source #
Split a qualified start symbol ("Main.start") into module and occurrence parts.
localOcc :: Var -> Text Source #
The display occurrence for a local binder: real source names pass
through; GHC-machine names (system names, plus the desugarer's
ds/wild/eta family by occurrence shape -- isSystemName alone
misses some) get the compiler-owned $ prefix, so downstream naming
policy knows they are free to rename, merge, or discard rather than
worth preserving as signal names. The shape check defers to a real
source span: a user's own binder named eta or ds keeps its name.
Advisory only: uniqueness never depends on the marker.
erasedArg :: CoreExpr -> Bool Source #
Arguments the translation erases: types, coercions, and evidence -- except evidence for user classes, which is kept as ordinary data (dictionaries as values; specialization plus the partial evaluator's dictionary-let substitution and case-of-known-constructor eliminate them).
userPred :: Type -> Bool Source #
Is this a user-class predicate type -- or evidence for one under quantifiers and a context (an instance's dfun type)? A class defined in a home module (approximated by defining-module namespace, like the tycon table's fallback): built-in evidence (KnownNat, Monad, HasCallStack, ...) is external and erased; classes in the user's own modules are data, and their dfuns -- contexted instances included -- are ordinary definitions.
tyConModule :: TyCon -> Maybe ModuleName Source #
tyConKey :: TyCon -> (String, String) Source #
Key for the external tycon table: defining module and occurrence.
tyConTable :: [((String, String), (Text, Int))] Source #
External tycons mapped by (defining module, occurrence) to (Eidos name, number of leading type args to drop).
vocabTable :: [(Text, [(Text, Text)])] Source #
Base combinators supported via synthesized (INLINE) Eidos definitions
(see bridgeBaseVocab in ReWire.GHC.ToEidos); outer key: defining
module; inner: occurrence -> Eidos name.
maybeTyName :: Text Source #
eitherTyName :: Text Source #