toString for each squiggleValue

This commit is contained in:
Umur Ozkul 2022-08-27 20:24:13 +02:00
parent 2fc325beb6
commit e2491bda88
8 changed files with 52 additions and 22 deletions

View File

@ -4,3 +4,7 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue
@genType
let getValues = (v: squiggleValue_Array): array<squiggleValue> =>
ReducerInterface_InternalExpressionValue.arrayToValueArray(v)
@genType
let toString = (v: squiggleValue_Array): string =>
ReducerInterface_InternalExpressionValue.toStringArray(v)

View File

@ -1 +1,5 @@
@genType type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambdaDeclaration //re-export
@genType
let toString = (v: squiggleValue_Declaration): string =>
ReducerInterface_InternalExpressionValue.toStringDeclaration(v)

View File

@ -1 +1,5 @@
@genType type squiggleValue_Distribution = ForTS_Distribution.distribution
@genType
let toString = (v: squiggleValue_Distribution): string =>
ReducerInterface_InternalExpressionValue.toStringDistribution(v)

View File

@ -1 +1,5 @@
@genType type squiggleValue_Lambda = ReducerInterface_InternalExpressionValue.lambdaValue //re-export
@genType
let toString = (v: squiggleValue_Lambda): string =>
ReducerInterface_InternalExpressionValue.toStringLambda(v)

View File

@ -4,3 +4,7 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
@genType
let getKeyValuePairs = (v: squiggleValue_Module): array<(string, squiggleValue)> =>
ReducerInterface_InternalExpressionValue.nameSpaceToKeyValuePairs(v)
@genType
let toString = (v: squiggleValue_Module): string =>
ReducerInterface_InternalExpressionValue.toStringNameSpace(v)

View File

@ -4,3 +4,6 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
@genType
let getKeyValuePairs = (value: squiggleValue_Record): array<(string, squiggleValue)> =>
ReducerInterface_InternalExpressionValue.recordToKeyValuePairs(value)
@genType
let toString = (v: squiggleValue_Record) => ReducerInterface_InternalExpressionValue.toStringMap(v)

View File

@ -4,3 +4,7 @@ type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
@genType
let getKeyValuePairs = (value: squiggleValue_Type): array<(string, squiggleValue)> =>
ReducerInterface_InternalExpressionValue.recordToKeyValuePairs(value)
@genType
let toString = (value: squiggleValue_Type): string =>
ReducerInterface_InternalExpressionValue.toStringType(value)

View File

@ -41,7 +41,7 @@ type functionCall = (string, array<t>)
let rec toString = aValue =>
switch aValue {
| IEvArray(anArray) =>toStringArray(anArray)
| IEvArray(anArray) => toStringArray(anArray)
| IEvArrayString(anArray) => toStringArrayString(anArray)
| IEvBindings(m) => toStringBindings(m)
| IEvBool(aBool) => toStringBool(aBool)
@ -59,27 +59,30 @@ let rec toString = aValue =>
| IEvTypeIdentifier(id) => toStringTypeIdentifier(id)
| IEvVoid => toStringVoid
}
and toStringArray = (anArray) => {let args = anArray->Js.Array2.map(each => toString(each))->Js.Array2.toString
`[${args}]`}
and toStringArrayString = (anArray) => {
let args = anArray->Js.Array2.toString
`[${args}]`
}
and toStringBindings = (m) => `@${m->toStringNameSpace}`
and toStringBool = (aBool) => Js.String.make(aBool)
and toStringCall = (fName) => `:${fName}`
and toStringDate = (date) => DateTime.Date.toString(date)
and toStringDeclaration = (d) => Declaration.toString(d, r => toString(IEvLambda(r)))
and toStringDistribution = (dist) => GenericDist.toString(dist)
and toStringLambda = (lambdaValue) => `lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)`
and toStringFunction = (lambdaValue) => `function(${Js.Array2.toString(lambdaValue.parameters)})`
and toStringNumber = (aNumber) => Js.String.make(aNumber)
and toStringRecord = (aMap) => aMap->toStringMap
and toStringString = (aString) => `'${aString}'`
and toStringSymbol = (aString) => `:${aString}`
and toStringTimeDuration = (t) => DateTime.Duration.toString(t)
and toStringType = (aMap) => aMap->toStringMap
and toStringTypeIdentifier = (id) => `#${id}`
and toStringArray = anArray => {
let args = anArray->Js.Array2.map(each => toString(each))->Js.Array2.toString
`[${args}]`
}
and toStringArrayString = anArray => {
let args = anArray->Js.Array2.toString
`[${args}]`
}
and toStringBindings = m => `@${m->toStringNameSpace}`
and toStringBool = aBool => Js.String.make(aBool)
and toStringCall = fName => `:${fName}`
and toStringDate = date => DateTime.Date.toString(date)
and toStringDeclaration = d => Declaration.toString(d, r => toString(IEvLambda(r)))
and toStringDistribution = dist => GenericDist.toString(dist)
and toStringLambda = lambdaValue =>
`lambda(${Js.Array2.toString(lambdaValue.parameters)}=>internal code)`
and toStringFunction = lambdaValue => `function(${Js.Array2.toString(lambdaValue.parameters)})`
and toStringNumber = aNumber => Js.String.make(aNumber)
and toStringRecord = aMap => aMap->toStringMap
and toStringString = aString => `'${aString}'`
and toStringSymbol = aString => `:${aString}`
and toStringTimeDuration = t => DateTime.Duration.toString(t)
and toStringType = aMap => aMap->toStringMap
and toStringTypeIdentifier = id => `#${id}`
and toStringVoid = `()`
and toStringMap = aMap => {