squiggle/packages/squiggle-lang/__tests__/Reducer/Reducer_Helpers.res

23 lines
884 B
Plaintext
Raw Normal View History

// Reducer_Helpers
module ErrorValue = Reducer_ErrorValue
module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue
module InternalExpressionValue = ReducerInterface.InternalExpressionValue
module Module = Reducer_Category_Module
2022-06-24 10:15:38 +00:00
let removeDefaultsInternal = (iev: InternalExpressionValue.t) => {
switch iev {
2022-06-23 18:38:07 +00:00
| InternalExpressionValue.IEvModule(nameSpace) =>
Module.removeOther(
nameSpace,
ReducerInterface.StdLib.internalStdLib,
2022-06-23 18:38:07 +00:00
)->InternalExpressionValue.IEvModule
| value => value
}
}
2022-06-24 10:15:38 +00:00
let removeDefaultsExternal = (ev: ExternalExpressionValue.t): ExternalExpressionValue.t =>
ev->InternalExpressionValue.toInternal->removeDefaultsInternal->InternalExpressionValue.toExternal
let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal)
let rRemoveDefaultsExternal = r => Belt.Result.map(r, removeDefaultsExternal)