diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res index 582df17d..eed48ffc 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/FunctionRegistry_Core.res @@ -11,7 +11,6 @@ type rec frType = | FRTypeLambda | FRTypeRecord(frTypeRecord) | FRTypeArray(frType) - | FRTypeOption(frType) | FRTypeString | FRTypeVariant(array) and frTypeRecord = array @@ -24,7 +23,6 @@ and frTypeRecordParam = (string, frType) type rec frValue = | FRValueNumber(float) | FRValueDist(DistributionTypes.genericDist) - | FRValueOption(option) | FRValueArray(array) | FRValueDistOrNumber(frValueDistOrNumber) | FRValueRecord(frValueRecord) @@ -60,7 +58,6 @@ module FRType = { `record({${r->E.A2.fmap(input)->E.A2.joinWith(", ")}})` } | FRTypeArray(r) => `record(${toString(r)})` - | FRTypeOption(v) => `option(${toString(v)})` | FRTypeLambda => `lambda` | FRTypeString => `string` | FRTypeVariant(_) => "variant" @@ -75,7 +72,6 @@ module FRType = { | (FRTypeDistOrNumber, EvDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f))) | (FRTypeNumeric, EvNumber(f)) => Some(FRValueNumber(f)) | (FRTypeNumeric, EvDistribution(Symbolic(#Float(f)))) => Some(FRValueNumber(f)) - | (FRTypeOption(v), _) => Some(FRValueOption(matchWithExpressionValue(v, r))) | (FRTypeLambda, EvLambda(f)) => Some(FRValueLambda(f)) | (FRTypeArray(intendedType), EvArray(elements)) => { let el = elements->E.A2.fmap(matchWithExpressionValue(intendedType)) @@ -101,7 +97,6 @@ module FRType = { | FRValueDistOrNumber(FRValueNumber(n)) => EvNumber(n) | FRValueDistOrNumber(FRValueDist(n)) => EvDistribution(n) | FRValueDist(dist) => EvDistribution(dist) - | FRValueOption(Some(r)) => matchReverse(r) | FRValueArray(elements) => EvArray(elements->E.A2.fmap(matchReverse)) | FRValueRecord(frValueRecord) => { let record = @@ -113,7 +108,6 @@ module FRType = { | FRValueVariant(string) => EvString(string) } - // | FRValueOption(None) => break let matchWithExpressionValueArray = (inputs: array, args: array): option< array, > => { diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res index 8f3dea42..aa040fc2 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res @@ -57,7 +57,7 @@ let rec toString = aValue => | EvDistribution(dist) => GenericDist.toString(dist) | EvDate(date) => DateTime.Date.toString(date) | EvTimeDuration(t) => DateTime.Duration.toString(t) - | EvDeclaration(t) => "Declaration" + | EvDeclaration(d) => Declaration.toString(d, r => toString(EvLambda(r))) } and toStringRecord = aRecord => { let pairs = @@ -128,6 +128,7 @@ type expressionValueType = | EvtSymbol | EvtDate | EvtTimeDuration + | EvtDeclaration type functionCallSignature = CallSignature(string, array) type functionDefinitionSignature = @@ -147,6 +148,7 @@ let valueToValueType = value => | EvSymbol(_) => EvtSymbol | EvDate(_) => EvtDate | EvTimeDuration(_) => EvtTimeDuration + | EvDeclaration(_) => EvtDeclaration } let functionCallToCallSignature = (functionCall: functionCall): functionCallSignature => { @@ -168,6 +170,7 @@ let valueTypeToString = (valueType: expressionValueType): string => | EvtSymbol => `Symbol` | EvtDate => `Date` | EvtTimeDuration => `Duration` + | EvtDeclaration => `Declaration` } let functionCallSignatureToString = (functionCallSignature: functionCallSignature): string => { diff --git a/packages/squiggle-lang/src/rescript/Utility/Declaration.res b/packages/squiggle-lang/src/rescript/Utility/Declaration.res index d26e1833..871dd580 100644 --- a/packages/squiggle-lang/src/rescript/Utility/Declaration.res +++ b/packages/squiggle-lang/src/rescript/Utility/Declaration.res @@ -19,6 +19,24 @@ module ContinuousTimeArg = { } } +module Arg = { + let toString = (arg: arg) => { + switch arg { + | Float({min, max}) => + `Float({min: ${E.Float.with2DigitsPrecision(min)}, max: ${E.Float.with2DigitsPrecision( + max, + )}})` + | Date({min, max}) => + `Date({min: ${DateTime.Date.toString(min)}, max: ${DateTime.Date.toString(max)}})` + } + } +} + let make = (fn: 'a, args: array): declaration<'a> => { {fn: fn, args: args} } + +let toString = (r: declaration<'a>, fnToString): string => { + let args = r.args->E.A2.fmap(Arg.toString) |> E.A.joinWith(", ") + return`fn: ${fnToString(r.fn)}, args: [${args}]` +}