rewire-frontend-2.8: A Haskell-to-Verilog/VHDL compiler, front end (GHC driver, Eidos, Synolon)
Safe HaskellTrustworthy
LanguageHaskell2010

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

Documentation

uKey :: Var -> Int Source #

IntMap key for a binder (uniques are 64-bit as of GHC 9.10; low bits suffice as map keys within one compilation).

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.

conName :: DataCon -> Text Source #

Eidos names for constructors.

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).

erasedEv :: Type -> Bool Source #

Evidence to erase: everything but user-class dictionaries.

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.

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.