gibbon-0.3: A compiler for operating on serialized data
Safe HaskellSafe-Inferred
LanguageHaskell2010

Gibbon.L2.Typecheck

Synopsis

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

data TCError Source #

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

Instances

Instances details
Generic TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Associated Types

type Rep TCError :: Type -> Type Source #

Read TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Show TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

NFData TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Methods

rnf :: TCError -> () Source #

Eq TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Ord TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep TCError Source # 
Instance details

Defined in Gibbon.L2.Typecheck

newtype RegionSet Source #

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.

Constructors

RegionSet 

Fields

Instances

Instances details
Generic RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Associated Types

type Rep RegionSet :: Type -> Type Source #

Read RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Show RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

NFData RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Methods

rnf :: RegionSet -> () Source #

Eq RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Ord RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep RegionSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep RegionSet = D1 ('MetaData "RegionSet" "Gibbon.L2.Typecheck" "gibbon-0.3-inplace" 'True) (C1 ('MetaCons "RegionSet" 'PrefixI 'True) (S1 ('MetaSel ('Just "regSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set Var))))

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.

Constructors

LocationTypeState 

Fields

Instances

Instances details
Out LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Generic LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Associated Types

type Rep LocationTypeState :: Type -> Type Source #

Read LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Show LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

NFData LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Methods

rnf :: LocationTypeState -> () Source #

Eq LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Ord LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep LocationTypeState Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep LocationTypeState = D1 ('MetaData "LocationTypeState" "Gibbon.L2.Typecheck" "gibbon-0.3-inplace" 'True) (C1 ('MetaCons "LocationTypeState" 'PrefixI 'True) (S1 ('MetaSel ('Just "tsmap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map LocVar (Modality, Aliased)))))

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

Instances details
Out ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Generic ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Associated Types

type Rep ConstraintSet :: Type -> Type Source #

Read ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Show ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

NFData ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Methods

rnf :: ConstraintSet -> () Source #

Eq ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Ord ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep ConstraintSet Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep ConstraintSet = D1 ('MetaData "ConstraintSet" "Gibbon.L2.Typecheck" "gibbon-0.3-inplace" 'True) (C1 ('MetaCons "ConstraintSet" 'PrefixI 'True) (S1 ('MetaSel ('Just "constraintSet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set LocConstraint))))

data LocConstraint Source #

Constraints on locations. Used during typechecking. Roughly analogous to LocExp.

Constructors

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

Instances details
Out LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Generic LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Associated Types

type Rep LocConstraint :: Type -> Type Source #

Read LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Show LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

NFData LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Methods

rnf :: LocConstraint -> () Source #

Eq LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

Ord LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Rep LocConstraint Source # 
Instance details

Defined in Gibbon.L2.Typecheck

type Aliased = Bool Source #

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.

type TcM a = Except TCError a Source #

The type checking monad. Just for throwing errors, but could in the future be parameterized by whatever other logging, etc, monad we want the compiler to use.