added 'add' over EvDist, EvDist
This commit is contained in:
parent
bc1a73b0af
commit
cd231cb917
|
@ -41,7 +41,7 @@
|
||||||
},
|
},
|
||||||
"refmt": 3,
|
"refmt": 3,
|
||||||
"warnings": {
|
"warnings": {
|
||||||
"number": "+A-42-48-9-30-4-102"
|
"number": "+A-42-48-9-30-4-102-20-27-41"
|
||||||
},
|
},
|
||||||
"ppx-flags": []
|
"ppx-flags": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ type rec expressionValue =
|
||||||
| EvSymbol(string)
|
| EvSymbol(string)
|
||||||
| EvArray(array<expressionValue>)
|
| EvArray(array<expressionValue>)
|
||||||
| EvRecord(Js.Dict.t<expressionValue>)
|
| EvRecord(Js.Dict.t<expressionValue>)
|
||||||
|
| EvDist(GenericDist_Types.genericDist)
|
||||||
|
|
||||||
type functionCall = (string, array<expressionValue>)
|
type functionCall = (string, array<expressionValue>)
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ let rec toString = aValue =>
|
||||||
->Js.String.concatMany("")
|
->Js.String.concatMany("")
|
||||||
`{${pairs}}`
|
`{${pairs}}`
|
||||||
}
|
}
|
||||||
|
// | Dist() =>
|
||||||
}
|
}
|
||||||
|
|
||||||
let toStringWithType = aValue =>
|
let toStringWithType = aValue =>
|
||||||
|
@ -45,6 +47,7 @@ let toStringWithType = aValue =>
|
||||||
| EvSymbol(_) => `Symbol::${toString(aValue)}`
|
| EvSymbol(_) => `Symbol::${toString(aValue)}`
|
||||||
| EvArray(_) => `Array::${toString(aValue)}`
|
| EvArray(_) => `Array::${toString(aValue)}`
|
||||||
| EvRecord(_) => `Record::${toString(aValue)}`
|
| EvRecord(_) => `Record::${toString(aValue)}`
|
||||||
|
// | Dist(_) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
let argsToString = (args: array<expressionValue>): string => {
|
let argsToString = (args: array<expressionValue>): string => {
|
||||||
|
|
|
@ -13,10 +13,32 @@ module Sample = {
|
||||||
/*
|
/*
|
||||||
Map external calls of Reducer
|
Map external calls of Reducer
|
||||||
*/
|
*/
|
||||||
|
let env: GenericDist_GenericOperation.env = {
|
||||||
|
sampleCount: 100,
|
||||||
|
xyPointLength: 100,
|
||||||
|
}
|
||||||
|
|
||||||
let dispatch = (call: ExpressionValue.functionCall, chain): result<expressionValue, 'e> =>
|
let dispatch = (call: ExpressionValue.functionCall, chain): result<expressionValue, 'e> =>
|
||||||
switch call {
|
switch call {
|
||||||
| ("add", [EvNumber(a), EvNumber(b)]) => Sample.customAdd(a, b)->EvNumber->Ok
|
| ("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)
|
| call => chain(call)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user