added 'add' over EvDist, EvDist

This commit is contained in:
Quinn Dougherty 2022-03-31 16:44:52 -04:00
parent bc1a73b0af
commit cd231cb917
3 changed files with 27 additions and 2 deletions

View File

@ -41,7 +41,7 @@
},
"refmt": 3,
"warnings": {
"number": "+A-42-48-9-30-4-102"
"number": "+A-42-48-9-30-4-102-20-27-41"
},
"ppx-flags": []
}

View File

@ -12,6 +12,7 @@ type rec expressionValue =
| EvSymbol(string)
| EvArray(array<expressionValue>)
| EvRecord(Js.Dict.t<expressionValue>)
| EvDist(GenericDist_Types.genericDist)
type functionCall = (string, array<expressionValue>)
@ -35,6 +36,7 @@ let rec toString = aValue =>
->Js.String.concatMany("")
`{${pairs}}`
}
// | Dist() =>
}
let toStringWithType = aValue =>
@ -45,6 +47,7 @@ let toStringWithType = aValue =>
| EvSymbol(_) => `Symbol::${toString(aValue)}`
| EvArray(_) => `Array::${toString(aValue)}`
| EvRecord(_) => `Record::${toString(aValue)}`
// | Dist(_) =>
}
let argsToString = (args: array<expressionValue>): string => {

View File

@ -13,10 +13,32 @@ module Sample = {
/*
Map external calls of Reducer
*/
let env: GenericDist_GenericOperation.env = {
sampleCount: 100,
xyPointLength: 100,
}
let dispatch = (call: ExpressionValue.functionCall, chain): result<expressionValue, 'e> =>
switch call {
| ("add", [EvNumber(a), EvNumber(b)]) => Sample.customAdd(a, b)->EvNumber->Ok
| ("add", [EvDist(a), EvDist(b)]) => {
let x = GenericDist_GenericOperation.Output.toDistR(
GenericDist_GenericOperation.run(~env, FromDist(ToDistCombination(Algebraic, #Add, #Dist(b)), a))
)
switch x {
| Ok(thing) => Ok(EvDist(thing))
| Error(err) => Error(Reducer_ErrorValue.RETodo("")) // TODO:
}
}
| ("add", [EvNumber(a), EvDist(b)]) => {
let x = GenericDist_GenericOperation.Output.toDistR(
GenericDist_GenericOperation.run(~env, FromDist(ToDistCombination(Algebraic, #Add, #Dist(b)), a))
)
switch x {
| Ok(thing) => Ok(EvDist(thing))
| Error(err) => Error(Reducer_ErrorValue.RETodo("")) // TODO:
}
}
| call => chain(call)
/*