squiggle/packages/squiggle-lang/src/rescript/Reducer/Reducer_T.res
Vyacheslav Matyukhin 757d458ecf
more FR
2022-09-12 13:33:41 +04:00

51 lines
1.6 KiB
Plaintext

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>)
and lambdaBody = (array<value>, environment, reducerFn) => value
@genType.opaque
and lambdaValue = {
parameters: array<string>,
// context: nameSpace,
body: (array<value>, environment, reducerFn) => value,
}
@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(array<(expression, 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