squiggle/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res
Umur Ozkul ac9a468aa6 Reducer InternalExpressionValue created
this will allow complicated changes to execution without changing the typescript interface
2022-06-23 02:25:54 +02:00

25 lines
931 B
Plaintext

// Reducer_Helpers
module ErrorValue = Reducer_ErrorValue
module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue
module InternalExpressionValue = ReducerInterface.InternalExpressionValue
module Module = Reducer_Category_Module
let removeDefaultsInternal = (iev: InternalExpressionValue.expressionValue) => {
switch iev {
| InternalExpressionValue.IevModule(nameSpace) =>
Module.removeOther(
nameSpace,
ReducerInterface.StdLib.internalStdLib,
)->InternalExpressionValue.IevModule
| value => value
}
}
let removeDefaultsExternal = (
ev: ExternalExpressionValue.expressionValue,
): ExternalExpressionValue.expressionValue =>
ev->InternalExpressionValue.toInternal->removeDefaultsInternal->InternalExpressionValue.toExternal
let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal)
let rRemoveDefaultsExternal = r => Belt.Result.map(r, removeDefaultsExternal)