libcspm-1.0.0: A library providing a parser, type checker and evaluator for CSPM.

Safe HaskellNone

CSPM.DataStructures.Types

Contents

Synopsis

Data Structures

data Constraint Source

Constructors

CEq

Comparable for equality

COrd

Orderable

CInputable

Can be input on a channel

CSet

Can form sets of the type.

CYieldable

Is something that can be yielded on the right hand side of =>.

data Type Source

Constructors

TVar TypeVarRef 
TProc 
TInt 
TBool 
TChar 
TEvent 
TExtendable

Something that can be extended via some means to a given type.

After type-checking, the TypeVarRef will simply be a variable that contains Nothing. This means that it can be converted into an explicit TDotable via some unknown means, or directly to the return type.

The variable argument here has a slightly special role during unification. If it contains Nothing then this is extendable via some unknown means to the specified type. If it contains a TDotable argt rt, then we know that one of the arguments is argt, and the remaining arguments are rt, which must either be a Dotable or a variable. The meaning in the former sense is recursive, the meaning in the latter case is clear. If it contains TVar tvref, then this means tvref has replaced this argument variable.

We need to do the above as we may have multiple things that are extendable in the same way, so we need to sync the arguments together.

TExtendableEmptyDotList

This type is used only during type-checking, and is guaranteed to only ever appear at the top-level of the left-hand side of a TExtendable.

TSet Type 
TSeq Type 
TDot Type Type 
TMap 
TTuple [Type] 
TFunction [Type] Type 
TDotable Type Type 
TDatatype Name 

prettyPrintTypes :: [Type] -> [Doc]Source

Pretty prints several types using the same variable substitutions

Creation of Types

freshTypeVar :: MonadIO m => m TypeSource

Symbol Tables

Type Pointers

freshPType :: MonadIO m => m PTypeSource

readPType :: MonadIO m => PType -> m (Maybe Type)Source

setPType :: MonadIO m => PType -> Type -> m ()Source