diff --git a/packages/squiggle-lang/bsconfig.json b/packages/squiggle-lang/bsconfig.json index 64f5ffc1..4af37cb2 100644 --- a/packages/squiggle-lang/bsconfig.json +++ b/packages/squiggle-lang/bsconfig.json @@ -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": [] } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res index 8c94d752..2ad3a402 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res @@ -12,6 +12,7 @@ type rec expressionValue = | EvSymbol(string) | EvArray(array) | EvRecord(Js.Dict.t) + | EvDist(GenericDist_Types.genericDist) type functionCall = (string, array) @@ -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): string => { diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index 4f726650..608c9792 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -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 => 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) /*