define lambdaValue record as payload
This commit is contained in:
parent
087596ec43
commit
c0fad8c668
|
@ -26,10 +26,10 @@ let eFunction = (fName: string, lispArgs: list<expression>): expression => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let eLambda = (parameters: array<string>, context, expr) =>
|
let eLambda = (parameters: array<string>, context, expr) =>
|
||||||
BExpressionValue.EvLambda(
|
BExpressionValue.EvLambda({
|
||||||
parameters,
|
parameters: parameters,
|
||||||
context,
|
context: context,
|
||||||
expr->castExpressionToInternalCode,
|
body: expr->castExpressionToInternalCode}
|
||||||
)->BExpressionT.EValue
|
)->BExpressionT.EValue
|
||||||
|
|
||||||
let eNumber = aNumber => aNumber->BExpressionValue.EvNumber->BExpressionT.EValue
|
let eNumber = aNumber => aNumber->BExpressionValue.EvNumber->BExpressionT.EValue
|
||||||
|
|
|
@ -30,6 +30,6 @@ let applyParametersToLambda = (
|
||||||
reducer(newExpression, bindings, environment)
|
reducer(newExpression, bindings, environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
let doLambdaCall = ((parameters, context, internal), args, environment, reducer) => {
|
let doLambdaCall = (lambdaValue: ExpressionValue.lambdaValue, args, environment, reducer) => {
|
||||||
applyParametersToLambda(internal, parameters, args, context, environment, reducer)
|
applyParametersToLambda(lambdaValue.body, lambdaValue.parameters, args, lambdaValue.context, environment, reducer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,19 @@ type rec expressionValue =
|
||||||
| EvBool(bool)
|
| EvBool(bool)
|
||||||
| EvCall(string) // External function call
|
| EvCall(string) // External function call
|
||||||
| EvDistribution(DistributionTypes.genericDist)
|
| EvDistribution(DistributionTypes.genericDist)
|
||||||
| EvLambda((array<string>, record, internalCode))
|
| EvLambda(lambdaValue)
|
||||||
| EvNumber(float)
|
| EvNumber(float)
|
||||||
| EvRecord(record)
|
| EvRecord(record)
|
||||||
| EvString(string)
|
| EvString(string)
|
||||||
| EvSymbol(string)
|
| EvSymbol(string)
|
||||||
and record = Js.Dict.t<expressionValue>
|
and record = Js.Dict.t<expressionValue>
|
||||||
|
and externalBindings = record
|
||||||
|
and lambdaValue = {
|
||||||
|
parameters: array<string>,
|
||||||
|
context: externalBindings,
|
||||||
|
body: internalCode,
|
||||||
|
}
|
||||||
|
|
||||||
@genType
|
|
||||||
type externalBindings = record
|
|
||||||
@genType
|
@genType
|
||||||
let defaultExternalBindings: externalBindings = Js.Dict.empty()
|
let defaultExternalBindings: externalBindings = Js.Dict.empty()
|
||||||
|
|
||||||
|
@ -41,8 +45,8 @@ let rec toString = aValue =>
|
||||||
}
|
}
|
||||||
| EvBool(aBool) => Js.String.make(aBool)
|
| EvBool(aBool) => Js.String.make(aBool)
|
||||||
| EvCall(fName) => `:${fName}`
|
| EvCall(fName) => `:${fName}`
|
||||||
| EvLambda((parameters, _context, _internalCode)) =>
|
| EvLambda(lambdaValue) =>
|
||||||
`lambda(${Js.Array2.toString(parameters)}=>internal)`
|
`lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)`
|
||||||
| EvNumber(aNumber) => Js.String.make(aNumber)
|
| EvNumber(aNumber) => Js.String.make(aNumber)
|
||||||
| EvString(aString) => `'${aString}'`
|
| EvString(aString) => `'${aString}'`
|
||||||
| EvSymbol(aString) => `:${aString}`
|
| EvSymbol(aString) => `:${aString}`
|
||||||
|
@ -65,7 +69,7 @@ let toStringWithType = aValue =>
|
||||||
| EvBool(_) => `Bool::${toString(aValue)}`
|
| EvBool(_) => `Bool::${toString(aValue)}`
|
||||||
| EvCall(_) => `Call::${toString(aValue)}`
|
| EvCall(_) => `Call::${toString(aValue)}`
|
||||||
| EvDistribution(_) => `Distribution::${toString(aValue)}`
|
| EvDistribution(_) => `Distribution::${toString(aValue)}`
|
||||||
| EvLambda((_parameters, _context, _internalCode)) => `Lambda::${toString(aValue)}`
|
| EvLambda(_) => `Lambda::${toString(aValue)}`
|
||||||
| EvNumber(_) => `Number::${toString(aValue)}`
|
| EvNumber(_) => `Number::${toString(aValue)}`
|
||||||
| EvRecord(_) => `Record::${toString(aValue)}`
|
| EvRecord(_) => `Record::${toString(aValue)}`
|
||||||
| EvString(_) => `String::${toString(aValue)}`
|
| EvString(_) => `String::${toString(aValue)}`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user