diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res index 93b99f34..9d1c6669 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -274,8 +274,7 @@ module Matcher = { module Registry = { let _findExactMatches = (r: registry, fnName: string, args: array) => { - let functionMatchPairs = - r.functions->E.A2.fmap(l => (l, Function.match(l, fnName, args))) + let functionMatchPairs = r.functions->E.A2.fmap(l => (l, Function.match(l, fnName, args))) let fullMatch = functionMatchPairs->E.A.getBy(((_, match)) => Match.isFullMatch(match)) fullMatch->E.O.bind(((fn, match)) => switch match { @@ -416,9 +415,10 @@ module Registry = { r.functions->E.A2.fmap(fn => fn.examples->E.A2.fmap(example => (fn, example)))->E.A.concatMany let buildFnNameDict = (r: array): fnNameDict => { - let allDefinitionsWithFns = r - ->E.A2.fmap(fn => fn.definitions->E.A2.fmap(definitions => (fn, definitions))) - ->E.A.concatMany + let allDefinitionsWithFns = + r + ->E.A2.fmap(fn => fn.definitions->E.A2.fmap(definitions => (fn, definitions))) + ->E.A.concatMany let functionsWithFnNames = allDefinitionsWithFns ->E.A2.fmap(((fn, def)) => { @@ -440,7 +440,7 @@ module Registry = { cacheAsArray->Js.Dict.fromArray } - let make = (fns: array):registry => { + let make = (fns: array): registry => { let dict = buildFnNameDict(fns) {functions: fns, fnNameDict: dict} } diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res index 1699ef96..9b0f6737 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Library.res @@ -9,4 +9,4 @@ let fnList = Belt.Array.concatMany([ ]) let registry = FunctionRegistry_Core.Registry.make(fnList) -let dispatch = FunctionRegistry_Core.Registry.dispatch(registry) \ No newline at end of file +let dispatch = FunctionRegistry_Core.Registry.dispatch(registry) diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index 8a121cd0..43a1375c 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -19,13 +19,17 @@ let dispatch = (call: InternalExpressionValue.functionCall, environment, chain): /* If your dispatch is too big you can divide it into smaller dispatches and pass the call so that it gets called finally. + The final chain(call) invokes the builtin default functions of the interpreter. + Via chain(call), all MathJs operators and functions are available for string, number , boolean, array and record .e.g + - / * > >= < <= == /= not and or sin cos log ln concat, etc. + // See https://mathjs.org/docs/expressions/syntax.html // See https://mathjs.org/docs/reference/functions.html + Remember from the users point of view, there are no different modules: // "doSth( constructorType1 )" // "doSth( constructorType2 )" doSth gets dispatched to the correct module because of the type signature. You get function and operator abstraction for free. You don't need to combine different implementations into one type. That would be duplicating the repsonsibility of the dispatcher. -*/ \ No newline at end of file +*/ diff --git a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res index 50c8dd2f..ce74f476 100644 --- a/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res +++ b/packages/squiggle-lang/src/rescript/SquiggleLibrary/SquiggleLibrary_Math.res @@ -18,6 +18,5 @@ let mathBindings: Bindings.t = ->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IEvNumber(v))) ->Bindings.fromArray -//TODO: This should be in a different place. let makeBindings = (previousBindings: Bindings.t): Bindings.t => previousBindings->Bindings.merge(mathBindings)