flocc-pffb

Stabilityexperimental
Maintainerdeveloper@flocc.net
Safe HaskellNone

Compiler.Types2.TermBuilder

Description

For more information please see http://www.flocc.net/

Synopsis

Documentation

buildTermsForExpr :: (Show t, ShowP t, Eq t, Monad a) => FuncEnv t -> Expr -> (FuncEnv t -> Expr -> StateT (FuncEnv t) (StateT IdxSet a) ([FuncConstr t], FuncTerm t)) -> StateT (FuncEnv t) (StateT IdxSet a) ([FuncConstr t], FuncTerm t)

Helper function for building term environments for expr trees. May be called from an overriding function (with the overriding |function passed as the third argument so that control can be passed back to it in the recursive case).

performConstraintAnalysis :: (Monad a, Eq t, Show l, Show t, ShowP t) => (TermEnv l t -> Expr -> StateT (TermEnv l t) (StateT IdxSet a) ([Constr (Term l t)], Term l t)) -> TermEnv l t -> Expr -> StateT IdxSet a (Either (TermEnv l t) (Constr (Term l t)))

Takes a variable environment, term builder function and expression and returns either |a unified term environment solution to the analysis, or a failing constraint.

scm :: Show t => [FuncTerm t] -> FuncTerm t -> FuncScheme t

tup :: [FuncTerm t] -> FuncTerm t

fun :: FuncTerm t -> FuncTerm t -> FuncTerm t

initTermEnvInState :: Monad a => Term l t -> IdxTree -> StateT (TermEnvStack l t) a ()

Initialize the current level of the TermEnvStack using this IdxTree pattern

data ExpLbl

Constructors

ProdLbl Idx 
IfLbl Idx 

type Substs t = [Subst t]

A list of substitutions

composeSubsts :: Substs t -> Substs t -> Substs t

Compose substitution lists such that s2 is applied first, then s1

applySubstsToTerm :: Eq t => Substs (Term l t) -> Term l t -> Term l t

Apply all substitutions to the term

applySubstsToEnv :: (Eq t, Show t, Show l) => Substs (Term l t) -> TermEnv l t -> TermEnv l t

Apply all substitutions to the term/scheme environment

applySubstsToConstrs :: Eq t => Substs (Term l t) -> [Constr (Term l t)] -> [Constr (Term l t)]

Apply all substitutions to the constraint list

type InferenceMonad t m = StateT (FuncEnv t) (StateT IdxSet m) (Substs (FuncTerm t), FuncTerm t)

The state monad used by inference functions

type InferenceFunction t m = FuncEnv t -> Expr -> InferenceMonad t m

The type of an inference function

inferTerms :: (Monad m, Show t, ShowP t, Eq t) => InferenceFunction t m -> FuncEnv t -> Expr -> InferenceMonad t m

Base function for all term inferencers

inferNewTerms :: (Monad m, Show t, ShowP t, Eq t) => InferenceFunction t m -> FuncEnv t -> Expr -> InferenceMonad t m

Term inferencer function where only terms who's terms |do not already exist in the state are investigated.

runTermInferencer :: (Monad m, Show t, ShowP t, Eq t) => InferenceFunction t m -> FuncEnv t -> Expr -> StateT IdxSet m (Either (FuncEnv t) (Constr (Term ExpLbl t)))

Function that performs term inference using the inference function provided

runNewTermInferencer :: (Monad m, Show t, ShowP t, Eq t) => InferenceFunction t m -> FuncEnv t -> FuncEnv t -> Expr -> StateT IdxSet m (Either (FuncEnv t) (Constr (Term ExpLbl t)))

Function that performs term inference using the inference function provided

inferTermsFoldF :: (Monad m, Show t, Eq t) => InferenceFunction t m -> InferenceFoldType t -> Expr -> StateT (FuncEnv t) (StateT IdxSet m) (InferenceFoldType t)

Binary operator to fold over a list of expressions. |Note: Term list returned in reverse order, need to apply reverse to it.

inferEqTermsFoldF :: (Monad m, Show t, Eq t) => InferenceFunction t m -> InferenceFoldType t -> Expr -> StateT (FuncEnv t) (StateT IdxSet m) (InferenceFoldType t)

Binary operator to fold over a list of expressions, with |the added constraint that all terms in the list are equal. |Note: Term list returned in reverse order, need to apply reverse to it.

addAConstraint :: (Show t, ShowP t, Show l, Eq t) => Term l t -> Term l t -> Term l t -> Maybe (Term l t)

addAConstraint takes three terms, and tries to unify the latter two |and apply any substitutions to the first.

buildForIdxTree :: Monad a => IdxTree -> StateT (FuncEnv t) (StateT IdxSet a) (FuncEnv t, FuncTerm t)