2022-09-11 15:22:07 +00:00
type environment = GenericDist.env
@genType.opaque
type rec value =
| IEvArray(arrayValue)
| IEvArrayString(array<string>)
| IEvBool(bool)
// | IEvCall(string) // External function call
| IEvDate(Js.Date.t)
| IEvDeclaration(lambdaDeclaration)
| IEvDistribution(DistributionTypes.genericDist)
| IEvLambda(lambdaValue)
| IEvBindings(nameSpace)
| IEvNumber(float)
| IEvRecord(map)
| IEvString(string)
// | IEvSymbol(string)
| IEvTimeDuration(float)
| IEvType(map)
| IEvTypeIdentifier(string)
| IEvVoid
@genType.opaque and arrayValue = array<value>
@genType.opaque and map = Belt.Map.String.t<value>
@genType.opaque and nameSpace = NameSpace(Belt.MutableMap.String.t<value>, option<nameSpace>)
2022-09-11 16:57:28 +00:00
and lambdaBody = (array<value>, environment, reducerFn) => value
2022-09-11 15:22:07 +00:00
@genType.opaque
2022-09-11 16:57:28 +00:00
and lambdaValue = {
2022-09-11 15:22:07 +00:00
parameters: array<string>,
2022-09-11 16:57:28 +00:00
// context: nameSpace,
2022-09-11 15:22:07 +00:00
body: (array<value>, environment, reducerFn) => value,
2022-09-11 16:57:28 +00:00
}
2022-09-11 15:22:07 +00:00
@genType.opaque and lambdaDeclaration = Declaration.declaration<lambdaValue>
and expression =
| EBlock(array<expression>)
| EProgram(array<expression>) // programs are similar to blocks, but don't create an inner scope. there can be only one program at the top level of the expression.
| EArray(array<expression>)
| ERecord(Belt.Map.String.t<expression>)
| ESymbol(string)
| ETernary(expression, expression, expression)
| EAssign(string, expression)
| ECall(expression, array<expression>)
| ELambda(array<string>, expression)
| EValue(value)
and context = {
bindings: nameSpace,
environment: environment,
}
and reducerFn = (expression, context) => value