Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- tcExp :: DDefs Ty2 -> Env2 Ty2 -> FunDefs2 -> ConstraintSet -> RegionSet -> LocationTypeState -> Exp -> TcM (Ty2, LocationTypeState)
- tcProg :: Prog2 -> PassM Prog2
- data TCError
- = GenericTC String Exp
- | VarNotFoundTC Var Exp
- | UnsupportedExpTC Exp
- | LocationTC String Exp LocVar LocVar
- | ModalityTC String Exp LocVar LocationTypeState
- newtype RegionSet = RegionSet {}
- newtype LocationTypeState = LocationTypeState {}
- newtype ConstraintSet = ConstraintSet {}
- data LocConstraint
- type Aliased = Bool
- type TcM a = Except TCError a
Documentation
tcExp :: DDefs Ty2 -> Env2 Ty2 -> FunDefs2 -> ConstraintSet -> RegionSet -> LocationTypeState -> Exp -> TcM (Ty2, LocationTypeState) Source #
Check an expression. Given the data definitions, an general type environment, a function map, a constraint set, a region set, an (input) location state map, and the expression, this function will either throw an error, or return a pair of expression type and new location state map.
tcProg :: Prog2 -> PassM Prog2 Source #
Main entry point, checks a whole program (functions and main body).
These are the kinds of errors that the type checker may throw. There are a few named errors that I thought would be common, like variables not being found, locations being used incorrectly, etc. For other errors, there's a GenericTC form that takes some expression and string (containing an error message).
GenericTC String Exp | |
VarNotFoundTC Var Exp | |
UnsupportedExpTC Exp | |
LocationTC String Exp LocVar LocVar | |
ModalityTC String Exp LocVar LocationTypeState |
Instances
Generic TCError Source # | |
Read TCError Source # | |
Show TCError Source # | |
NFData TCError Source # | |
Defined in Gibbon.L2.Typecheck | |
Eq TCError Source # | |
Ord TCError Source # | |
type Rep TCError Source # | |
Defined in Gibbon.L2.Typecheck |
A region set is (as you would expect) a set of regions. They are the regions that are currently live while checking a particular expression.
Instances
Generic RegionSet Source # | |
Read RegionSet Source # | |
Show RegionSet Source # | |
NFData RegionSet Source # | |
Defined in Gibbon.L2.Typecheck | |
Eq RegionSet Source # | |
Ord RegionSet Source # | |
Defined in Gibbon.L2.Typecheck | |
type Rep RegionSet Source # | |
Defined in Gibbon.L2.Typecheck |
newtype LocationTypeState Source #
A map from locations to their type state. This tracks the current state of a location at a certain point in a program. The type checker threads this through by taking an input map that represents the location states before checking a particular expression, and returns an output map that represents the location states after checking that particular expression. All we need to know in this map is whether each location is an input or output location, and whether we've taken an offset of the location in a letloc form.
Instances
newtype ConstraintSet Source #
A set of constraints (which are re-used location expressions) which encode relationships between locations. These are used by the type checker to verify that locations are used correctly.
The following are valid constraints: * StartOfC LocVar Region * AfterConstantC Int LocVar LocVar * AfterVariableC Var LocVar LocVar * InRegionC LocVar Region * FromEndC
While the first four can appear in syntax before RouteEnds, the fifth (fromEnd) should only be introduced by the RouteEnds pass.
Instances
data LocConstraint Source #
Constraints on locations. Used during typechecking. Roughly analogous to LocExp.
StartOfC LocVar Region | Location is equal to start of this region. Can't attach haddocks to data constructor arguments with < GHC 8.4.2 See https://github.com/haskell/haddock/pull/709. |
AfterConstantC Int LocVar LocVar | |
AfterVariableC Var LocVar LocVar | |
InRegionC LocVar Region |
Instances
A location has been aliased if we have taken an offset of it while introducing a new location. These show up in the LocationTypeState below.