Added Declaration toString
This commit is contained in:
parent
529a8a6763
commit
20f901e3f8
|
@ -11,7 +11,6 @@ type rec frType =
|
||||||
| FRTypeLambda
|
| FRTypeLambda
|
||||||
| FRTypeRecord(frTypeRecord)
|
| FRTypeRecord(frTypeRecord)
|
||||||
| FRTypeArray(frType)
|
| FRTypeArray(frType)
|
||||||
| FRTypeOption(frType)
|
|
||||||
| FRTypeString
|
| FRTypeString
|
||||||
| FRTypeVariant(array<string>)
|
| FRTypeVariant(array<string>)
|
||||||
and frTypeRecord = array<frTypeRecordParam>
|
and frTypeRecord = array<frTypeRecordParam>
|
||||||
|
@ -24,7 +23,6 @@ and frTypeRecordParam = (string, frType)
|
||||||
type rec frValue =
|
type rec frValue =
|
||||||
| FRValueNumber(float)
|
| FRValueNumber(float)
|
||||||
| FRValueDist(DistributionTypes.genericDist)
|
| FRValueDist(DistributionTypes.genericDist)
|
||||||
| FRValueOption(option<frValue>)
|
|
||||||
| FRValueArray(array<frValue>)
|
| FRValueArray(array<frValue>)
|
||||||
| FRValueDistOrNumber(frValueDistOrNumber)
|
| FRValueDistOrNumber(frValueDistOrNumber)
|
||||||
| FRValueRecord(frValueRecord)
|
| FRValueRecord(frValueRecord)
|
||||||
|
@ -60,7 +58,6 @@ module FRType = {
|
||||||
`record({${r->E.A2.fmap(input)->E.A2.joinWith(", ")}})`
|
`record({${r->E.A2.fmap(input)->E.A2.joinWith(", ")}})`
|
||||||
}
|
}
|
||||||
| FRTypeArray(r) => `record(${toString(r)})`
|
| FRTypeArray(r) => `record(${toString(r)})`
|
||||||
| FRTypeOption(v) => `option(${toString(v)})`
|
|
||||||
| FRTypeLambda => `lambda`
|
| FRTypeLambda => `lambda`
|
||||||
| FRTypeString => `string`
|
| FRTypeString => `string`
|
||||||
| FRTypeVariant(_) => "variant"
|
| FRTypeVariant(_) => "variant"
|
||||||
|
@ -75,7 +72,6 @@ module FRType = {
|
||||||
| (FRTypeDistOrNumber, EvDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f)))
|
| (FRTypeDistOrNumber, EvDistribution(f)) => Some(FRValueDistOrNumber(FRValueDist(f)))
|
||||||
| (FRTypeNumeric, EvNumber(f)) => Some(FRValueNumber(f))
|
| (FRTypeNumeric, EvNumber(f)) => Some(FRValueNumber(f))
|
||||||
| (FRTypeNumeric, EvDistribution(Symbolic(#Float(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))
|
| (FRTypeLambda, EvLambda(f)) => Some(FRValueLambda(f))
|
||||||
| (FRTypeArray(intendedType), EvArray(elements)) => {
|
| (FRTypeArray(intendedType), EvArray(elements)) => {
|
||||||
let el = elements->E.A2.fmap(matchWithExpressionValue(intendedType))
|
let el = elements->E.A2.fmap(matchWithExpressionValue(intendedType))
|
||||||
|
@ -101,7 +97,6 @@ module FRType = {
|
||||||
| FRValueDistOrNumber(FRValueNumber(n)) => EvNumber(n)
|
| FRValueDistOrNumber(FRValueNumber(n)) => EvNumber(n)
|
||||||
| FRValueDistOrNumber(FRValueDist(n)) => EvDistribution(n)
|
| FRValueDistOrNumber(FRValueDist(n)) => EvDistribution(n)
|
||||||
| FRValueDist(dist) => EvDistribution(dist)
|
| FRValueDist(dist) => EvDistribution(dist)
|
||||||
| FRValueOption(Some(r)) => matchReverse(r)
|
|
||||||
| FRValueArray(elements) => EvArray(elements->E.A2.fmap(matchReverse))
|
| FRValueArray(elements) => EvArray(elements->E.A2.fmap(matchReverse))
|
||||||
| FRValueRecord(frValueRecord) => {
|
| FRValueRecord(frValueRecord) => {
|
||||||
let record =
|
let record =
|
||||||
|
@ -113,7 +108,6 @@ module FRType = {
|
||||||
| FRValueVariant(string) => EvString(string)
|
| FRValueVariant(string) => EvString(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// | FRValueOption(None) => break
|
|
||||||
let matchWithExpressionValueArray = (inputs: array<t>, args: array<expressionValue>): option<
|
let matchWithExpressionValueArray = (inputs: array<t>, args: array<expressionValue>): option<
|
||||||
array<frValue>,
|
array<frValue>,
|
||||||
> => {
|
> => {
|
||||||
|
|
|
@ -57,7 +57,7 @@ let rec toString = aValue =>
|
||||||
| EvDistribution(dist) => GenericDist.toString(dist)
|
| EvDistribution(dist) => GenericDist.toString(dist)
|
||||||
| EvDate(date) => DateTime.Date.toString(date)
|
| EvDate(date) => DateTime.Date.toString(date)
|
||||||
| EvTimeDuration(t) => DateTime.Duration.toString(t)
|
| EvTimeDuration(t) => DateTime.Duration.toString(t)
|
||||||
| EvDeclaration(t) => "Declaration"
|
| EvDeclaration(d) => Declaration.toString(d, r => toString(EvLambda(r)))
|
||||||
}
|
}
|
||||||
and toStringRecord = aRecord => {
|
and toStringRecord = aRecord => {
|
||||||
let pairs =
|
let pairs =
|
||||||
|
@ -128,6 +128,7 @@ type expressionValueType =
|
||||||
| EvtSymbol
|
| EvtSymbol
|
||||||
| EvtDate
|
| EvtDate
|
||||||
| EvtTimeDuration
|
| EvtTimeDuration
|
||||||
|
| EvtDeclaration
|
||||||
|
|
||||||
type functionCallSignature = CallSignature(string, array<expressionValueType>)
|
type functionCallSignature = CallSignature(string, array<expressionValueType>)
|
||||||
type functionDefinitionSignature =
|
type functionDefinitionSignature =
|
||||||
|
@ -147,6 +148,7 @@ let valueToValueType = value =>
|
||||||
| EvSymbol(_) => EvtSymbol
|
| EvSymbol(_) => EvtSymbol
|
||||||
| EvDate(_) => EvtDate
|
| EvDate(_) => EvtDate
|
||||||
| EvTimeDuration(_) => EvtTimeDuration
|
| EvTimeDuration(_) => EvtTimeDuration
|
||||||
|
| EvDeclaration(_) => EvtDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
let functionCallToCallSignature = (functionCall: functionCall): functionCallSignature => {
|
let functionCallToCallSignature = (functionCall: functionCall): functionCallSignature => {
|
||||||
|
@ -168,6 +170,7 @@ let valueTypeToString = (valueType: expressionValueType): string =>
|
||||||
| EvtSymbol => `Symbol`
|
| EvtSymbol => `Symbol`
|
||||||
| EvtDate => `Date`
|
| EvtDate => `Date`
|
||||||
| EvtTimeDuration => `Duration`
|
| EvtTimeDuration => `Duration`
|
||||||
|
| EvtDeclaration => `Declaration`
|
||||||
}
|
}
|
||||||
|
|
||||||
let functionCallSignatureToString = (functionCallSignature: functionCallSignature): string => {
|
let functionCallSignatureToString = (functionCallSignature: functionCallSignature): string => {
|
||||||
|
|
|
@ -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<arg>): declaration<'a> => {
|
let make = (fn: 'a, args: array<arg>): declaration<'a> => {
|
||||||
{fn: fn, args: args}
|
{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}]`
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user