Lambda's Factory #
This module formalizes Lambda's factory, which is a mechanism to extend the
type checker (see Strata.DL.Lambda.LExprT) and partial evaluator (see
Strata.DL.Lambda.LExprEval) by providing a map from operations to their types
and optionally, denotations. The factory allows adding type checking and
evaluation support for new operations without modifying the implementation of
either or any core ASTs.
Also see Strata.DL.Lambda.IntBoolFactory for a concrete example of a factory.
A signature is a map from variable identifiers to types.
Equations
- Lambda.Signature IDMeta Ty = ListMap (Lambda.Identifier IDMeta) Ty
Instances For
Equations
- Lambda.Signature.format [] = Std.Format.text ""
- Lambda.Signature.format [(k, v)] = Std.format "(" ++ Std.format k ++ Std.format " : " ++ Std.format v ++ Std.format ")"
- Lambda.Signature.format ((k, v) :: rest) = Std.format "(" ++ Std.format k ++ Std.format " : " ++ Std.format v ++ Std.format ") " ++ Lambda.Signature.format rest
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Lambda.inline_if_constr_attr = "inline_if_constr"
Instances For
Equations
- Lambda.eval_if_constr_attr = "eval_if_constr"
Instances For
A Lambda factory function - instantiation of Func for Lambda expressions.
Universally quantified type identifiers, if any, appear before this signature and can quantify over the type identifiers in it.
Equations
Instances For
Helper constructor for LFunc to maintain backward compatibility.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lambda.instInhabitedLFuncOfMetadataOfIDMeta = { default := { name := default, inputs := [], output := Lambda.LMonoTy.bool } }
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- f.inputPolyTypes = List.map (fun (x : T.Identifier × Lambda.LMonoTy) => match x with | (id, mty) => (id, Lambda.LTy.forAll f.typeArgs mty)) f.inputs
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The type checker and partial evaluator for Lambda is parameterizable by
a user-provided Factory.
We don't have any "built-in" functions like +, -, etc. in (LExpr IDMeta) -- lambdas are our only tool. Factory gives us a way to add
support for concrete/symbolic evaluation and type checking for FunFactory
functions without actually modifying any core logic or the ASTs.
Equations
- Lambda.Factory T = Array (Lambda.LFunc T)
Instances For
Equations
Instances For
Equations
- Lambda.instInhabitedFactory = { default := Lambda.Factory.default }
Equations
- Lambda.instMembershipLFuncFactory = { mem := fun (x : Lambda.Factory T) (f : Lambda.LFunc T) => Array.Mem x f }
Equations
- F.getFunctionNames = Array.map (fun (f : Lambda.LFunc T) => f.name) F
Instances For
Equations
- F.getFactoryLFunc name = Array.find? (fun (fn : Lambda.LFunc T) => fn.name.name == name) F
Instances For
Add a function func to the factory F. Redefinitions are not allowed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Append a factory newF to an existing factory F, checking for redefinitions
along the way.
Equations
- F.addFactory newF = Array.foldlM (fun (factory : Lambda.Factory T) (func : Lambda.LFunc T) => factory.addFactoryFunc func) F newF
Instances For
Equations
Instances For
Equations
- Lambda.getLFuncCall.go (Lambda.LExpr.app m (Lambda.LExpr.app m_1 e' arg1) arg2) acc = Lambda.getLFuncCall.go e' ([arg1, arg2] ++ acc)
- Lambda.getLFuncCall.go (Lambda.LExpr.app m (Lambda.LExpr.op m_1 fn fnty) arg1) acc = (Lambda.LExpr.op m_1 fn fnty, [arg1] ++ acc)
- Lambda.getLFuncCall.go e acc = (e, acc)
Instances For
Equations
Instances For
If e is a call of a factory function, get the operator (.op), a list
of all the actuals, and the (LFunc IDMeta).
Equations
- One or more equations did not get rendered due to their size.