consistent to string for every value

This commit is contained in:
Umur Ozkul 2022-08-27 19:34:08 +02:00
parent efd4fd322c
commit 7b4e38a983

View File

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