diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res index d0d88b2a..aa27d7ec 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Dispatch/Reducer_Dispatch_BuiltIn.res @@ -255,11 +255,10 @@ let dispatch = (call: functionCall, environment, reducer: ExpressionT.reducerFn) errorValue, > => try { - let callInternalWithReducer = (call, environment) => callInternal(call, environment, reducer) let (fn, args) = call // There is a bug that prevents string match in patterns // So we have to recreate a copy of the string - ExternalLibrary.dispatch((Js.String.make(fn), args), environment, callInternalWithReducer) + ExternalLibrary.dispatch((Js.String.make(fn), args), environment, reducer, callInternal) } catch { | Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error | _ => RETodo("unhandled rescript exception")->Error diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index 3e6172c9..2a479bb5 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -23,7 +23,7 @@ let tryRegistry = ((fnName, args): InternalExpressionValue.functionCall, env) => ) } -let dispatch = (call: InternalExpressionValue.functionCall, environment, chain): result< +let dispatch = (call: InternalExpressionValue.functionCall, environment, reducer, chain): result< internalExpressionValue, 'e, > => { @@ -33,7 +33,7 @@ let dispatch = (call: InternalExpressionValue.functionCall, environment, chain): () => ReducerInterface_Duration.dispatch(call, environment), () => ReducerInterface_Number.dispatch(call, environment), () => tryRegistry(call, environment), - ])->E.O2.default(chain(call, environment)) + ])->E.O2.default(chain(call, environment, reducer)) } /* If your dispatch is too big you can divide it into smaller dispatches and pass the call so that it gets called finally.