cleanups; ReducerInterface is no more

This commit is contained in:
Vyacheslav Matyukhin 2022-09-19 23:10:09 +04:00
parent 7a0c10d895
commit b24cfbc328
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
56 changed files with 160 additions and 320 deletions

View File

@ -1,9 +0,0 @@
// Reducer_Helpers
module ErrorValue = Reducer_ErrorValue
module InternalExpressionValue = ReducerInterface.InternalExpressionValue
let removeDefaultsInternal = (iev: InternalExpressionValue.t) => {
iev // TODO - cleanup, noop
}
let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal)

View File

@ -1,6 +1,5 @@
module Expression = Reducer_Expression module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module ExpressionValue = ReducerInterface.InternalExpressionValue
module Parse = Reducer_Peggy_Parse module Parse = Reducer_Peggy_Parse
module Result = Belt.Result module Result = Belt.Result
module ToExpression = Reducer_Peggy_ToExpression module ToExpression = Reducer_Peggy_ToExpression
@ -24,8 +23,7 @@ let expectToExpressionToBe = (expr, answer, ~v="_", ()) => {
let a2 = let a2 =
rExpr rExpr
->Result.flatMap(expr => Expression.BackCompatible.evaluate(expr)) ->Result.flatMap(expr => Expression.BackCompatible.evaluate(expr))
->Reducer_Helpers.rRemoveDefaultsInternal ->Reducer_Value.toStringResultOkless
->ExpressionValue.toStringResultOkless
(a1, a2)->expect->toEqual((answer, v)) (a1, a2)->expect->toEqual((answer, v))
} }
} }

View File

@ -1,6 +1,3 @@
module Bindings = Reducer_Bindings
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
open Jest open Jest
open Reducer_Peggy_TestHelpers open Reducer_Peggy_TestHelpers

View File

@ -1,5 +1,4 @@
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
open Jest open Jest
open Reducer_Peggy_TestHelpers open Reducer_Peggy_TestHelpers
@ -144,9 +143,9 @@ describe("Peggy to Expression", () => {
describe("module", () => { describe("module", () => {
// testToExpression("Math.pi", "{:Math.pi}", ~v="3.141592653589793", ()) // testToExpression("Math.pi", "{:Math.pi}", ~v="3.141592653589793", ())
// Only.test("stdlibrary", () => { // Only.test("stdlibrary", () => {
// ReducerInterface_StdLib.internalStdLib // SquiggleLibrary_StdLib.stdLib
// ->IEvBindings // ->IEvBindings
// ->InternalExpressionValue.toString // ->Reducer_Value.toString
// ->expect // ->expect
// ->toBe("") // ->toBe("")
// }) // })

View File

@ -1,7 +1,6 @@
module ErrorValue = Reducer_ErrorValue module ErrorValue = Reducer_ErrorValue
module Expression = Reducer_Expression module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module InternalExpressionValue = ReducerInterface.InternalExpressionValue
open Jest open Jest
open Expect open Expect
@ -19,14 +18,13 @@ let expectParseToBe = (code: string, answer: string) =>
let expectEvalToBe = (code: string, answer: string) => let expectEvalToBe = (code: string, answer: string) =>
Expression.BackCompatible.evaluateString(code) Expression.BackCompatible.evaluateString(code)
->Reducer_Helpers.rRemoveDefaultsInternal ->Reducer_Value.toStringResult
->InternalExpressionValue.toStringResult
->expect ->expect
->toBe(answer) ->toBe(answer)
let expectEvalError = (code: string) => let expectEvalError = (code: string) =>
Expression.BackCompatible.evaluateString(code) Expression.BackCompatible.evaluateString(code)
->InternalExpressionValue.toStringResult ->Reducer_Value.toStringResult
->expect ->expect
->toMatch("Error\(") ->toMatch("Error\(")

View File

@ -1,5 +1,4 @@
// module Expression = Reducer_Expression // module Expression = Reducer_Expression
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// module Bindings = Reducer_Bindings // module Bindings = Reducer_Bindings
// module T = Reducer_Type_T // module T = Reducer_Type_T
// module TypeCompile = Reducer_Type_Compile // module TypeCompile = Reducer_Type_Compile
@ -10,7 +9,7 @@
// let myIevEval = (aTypeSourceCode: string) => // let myIevEval = (aTypeSourceCode: string) =>
// TypeCompile.ievFromTypeExpression(aTypeSourceCode, Expression.reduceExpressionInProject) // TypeCompile.ievFromTypeExpression(aTypeSourceCode, Expression.reduceExpressionInProject)
// let myIevEvalToString = (aTypeSourceCode: string) => // let myIevEvalToString = (aTypeSourceCode: string) =>
// myIevEval(aTypeSourceCode)->InternalExpressionValue.toStringResult // myIevEval(aTypeSourceCode)->Reducer_Value.toStringResult
// let myIevExpectEqual = (aTypeSourceCode, answer) => // let myIevExpectEqual = (aTypeSourceCode, answer) =>
// expect(myIevEvalToString(aTypeSourceCode))->toEqual(answer) // expect(myIevEvalToString(aTypeSourceCode))->toEqual(answer)

View File

@ -1,8 +1,6 @@
// module Bindings = Reducer_Bindings // module Bindings = Reducer_Bindings
// module ErrorValue = Reducer_ErrorValue // module ErrorValue = Reducer_ErrorValue
// module Expression = Reducer_Expression // module Expression = Reducer_Expression
// module ExpressionT = Reducer_Expression_T
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
// module T = Reducer_Type_T // module T = Reducer_Type_T
// module TypeChecker = Reducer_Type_TypeChecker // module TypeChecker = Reducer_Type_TypeChecker

View File

@ -1,7 +1,6 @@
// module Expression = Reducer_Expression // module Expression = Reducer_Expression
// module ExpressionT = Reducer_Expression_T // module ExpressionT = Reducer_Expression_T
// module ErrorValue = Reducer_ErrorValue // module ErrorValue = Reducer_ErrorValue
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// module Bindings = Reducer_Bindings // module Bindings = Reducer_Bindings
// module T = Reducer_Type_T // module T = Reducer_Type_T
// module TypeChecker = Reducer_Type_TypeChecker // module TypeChecker = Reducer_Type_TypeChecker

View File

@ -8,15 +8,13 @@
// module TypeChecker = Reducer_Type_TypeChecker // module TypeChecker = Reducer_Type_TypeChecker
// module TypeCompile = Reducer_Type_Compile // module TypeCompile = Reducer_Type_Compile
// open ReducerInterface_InternalExpressionValue
// type errorValue = Reducer_ErrorValue.errorValue // type errorValue = Reducer_ErrorValue.errorValue
// // Let's build a function to replace switch statements // // Let's build a function to replace switch statements
// // In dispatchChainPiece, we execute an return the result of execution if there is a type match. // // In dispatchChainPiece, we execute an return the result of execution if there is a type match.
// // Otherwise we return None so that the call chain can continue. // // Otherwise we return None so that the call chain can continue.
// // So we want to build a function like // // So we want to build a function like
// // dispatchChainPiece = (call: functionCall, accessors): option<result<internalExpressionValue, errorValue>> // // dispatchChainPiece = (call: functionCall, accessors): option<result<Reducer_T.value, errorValue>>
// // Use accessors.environment to get the environment finally. // // Use accessors.environment to get the environment finally.
// // Now lets make the dispatchChainPiece itself. // // Now lets make the dispatchChainPiece itself.
@ -28,9 +26,9 @@
// module Implementation = { // module Implementation = {
// let stringConcat = (a: string, b: string): string => Js.String2.concat(a, b) // let stringConcat = (a: string, b: string): string => Js.String2.concat(a, b)
// let arrayConcat = ( // let arrayConcat = (
// a: Js.Array2.t<internalExpressionValue>, // a: Js.Array2.t<Reducer_T.value>,
// b: Js.Array2.t<internalExpressionValue>, // b: Js.Array2.t<Reducer_T.value>,
// ): Js.Array2.t<internalExpressionValue> => Js.Array2.concat(a, b) // ): Js.Array2.t<Reducer_T.value> => Js.Array2.concat(a, b)
// let plot = _r => "yey, plotted" // let plot = _r => "yey, plotted"
// } // }
@ -104,7 +102,7 @@
// accessors: ProjectAccessorsT.t, // accessors: ProjectAccessorsT.t,
// reducer: Reducer_T.reducerFn, // reducer: Reducer_T.reducerFn,
// chain, // chain,
// ): result<internalExpressionValue, 'e> => { // ): result<Reducer_T.value, 'e> => {
// let dispatchChainPiece = makeMyDispatchChainPiece(reducer) // let dispatchChainPiece = makeMyDispatchChainPiece(reducer)
// dispatchChainPiece(call, accessors)->E.O2.defaultFn(() => chain(call, accessors, reducer)) // dispatchChainPiece(call, accessors)->E.O2.defaultFn(() => chain(call, accessors, reducer))
// } // }

View File

@ -1,11 +1,14 @@
open ReducerInterface.InternalExpressionValue
open Jest open Jest
open Expect open Expect
describe("ExpressionValue", () => { describe("ExpressionValue", () => {
test("argsToString", () => expect([IEvNumber(1.), IEvString("a")]->argsToString)->toBe("1,'a'")) test("argsToString", () => expect(
[IEvNumber(1.), IEvString("a")]->Reducer_Value.argsToString)->toBe("1,'a'")
)
test("toStringFunctionCall", () => test("toStringFunctionCall", () =>
expect(("fn", [IEvNumber(1.), IEvString("a")])->toStringFunctionCall)->toBe("fn(1,'a')") expect(
("fn", [IEvNumber(1.), IEvString("a")])->Reducer_Value.toStringFunctionCall)->toBe("fn(1,'a')"
)
) )
}) })

View File

@ -1,7 +1,5 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings
open Jest open Jest
open Expect open Expect

View File

@ -1,5 +1,4 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
@ -9,12 +8,12 @@ open Expect.Operators
let runFetchResult = (project, sourceId) => { let runFetchResult = (project, sourceId) => {
Project.run(project, sourceId) Project.run(project, sourceId)
Project.getResult(project, sourceId)->InternalExpressionValue.toStringResult Project.getResult(project, sourceId)->Reducer_Value.toStringResult
} }
let runFetchFlatBindings = (project, sourceId) => { let runFetchFlatBindings = (project, sourceId) => {
Project.run(project, sourceId) Project.run(project, sourceId)
Project.getBindings(project, sourceId)->InternalExpressionValue.toStringRecord Project.getBindings(project, sourceId)->Reducer_Value.toStringRecord
} }
test("test result true", () => { test("test result true", () => {

View File

@ -1,5 +1,4 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
@ -50,8 +49,8 @@ Case "Running a single source".
/* Let's display the result and bindings */ /* Let's display the result and bindings */
( (
result->InternalExpressionValue.toStringResult, result->Reducer_Value.toStringResult,
bindings->InternalExpressionValue.toStringRecord, bindings->Reducer_Value.toStringRecord,
)->expect == ("Ok(3)", "{}") )->expect == ("Ok(3)", "{}")
/* You've got 3 with empty bindings. */ /* You've got 3 with empty bindings. */
}) })
@ -64,8 +63,8 @@ Case "Running a single source".
let bindings = project->Project.getBindings("main") let bindings = project->Project.getBindings("main")
/* Now you have external bindings and external result. */ /* Now you have external bindings and external result. */
( (
result->InternalExpressionValue.toStringResult, result->Reducer_Value.toStringResult,
bindings->Reducer_T.IEvRecord->InternalExpressionValue.toString, bindings->Reducer_T.IEvRecord->Reducer_Value.toString,
)->expect == ("Ok(3)", "{}") )->expect == ("Ok(3)", "{}")
}) })
@ -74,13 +73,13 @@ Case "Running a single source".
let project = Project.createProject() let project = Project.createProject()
/* Optional. Set your custom environment anytime before running */ /* Optional. Set your custom environment anytime before running */
project->Project.setEnvironment(InternalExpressionValue.defaultEnvironment) project->Project.setEnvironment(Reducer_Context.defaultEnvironment)
project->Project.setSource("main", "1 + 2") project->Project.setSource("main", "1 + 2")
project->Project.runAll project->Project.runAll
let result = project->Project.getResult("main") let result = project->Project.getResult("main")
let _bindings = project->Project.getBindings("main") let _bindings = project->Project.getBindings("main")
result->InternalExpressionValue.toStringResult->expect == "Ok(3)" result->Reducer_Value.toStringResult->expect == "Ok(3)"
}) })
test("shortcut", () => { test("shortcut", () => {
@ -88,8 +87,8 @@ Case "Running a single source".
/* Examples above was to prepare you for the multi source tutorial. */ /* Examples above was to prepare you for the multi source tutorial. */
let (result, bindings) = Project.evaluate("1+2") let (result, bindings) = Project.evaluate("1+2")
( (
result->InternalExpressionValue.toStringResult, result->Reducer_Value.toStringResult,
bindings->InternalExpressionValue.toStringRecord, bindings->Reducer_Value.toStringRecord,
)->expect == ("Ok(3)", "{}") )->expect == ("Ok(3)", "{}")
}) })
}) })

View File

@ -1,5 +1,4 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
@ -32,8 +31,8 @@ describe("ReducerProject Tutorial", () => {
let bindings3 = project->Project.getBindings("source3") let bindings3 = project->Project.getBindings("source3")
( (
result3->InternalExpressionValue.toStringResult, result3->Reducer_Value.toStringResult,
bindings3->InternalExpressionValue.toStringRecord, bindings3->Reducer_Value.toStringRecord,
)->expect == ("Ok(())", "{z: 3}") )->expect == ("Ok(())", "{z: 3}")
}) })
@ -58,8 +57,8 @@ describe("ReducerProject Tutorial", () => {
let bindings3 = project->Project.getBindings("source3") let bindings3 = project->Project.getBindings("source3")
( (
result3->InternalExpressionValue.toStringResult, result3->Reducer_Value.toStringResult,
bindings3->InternalExpressionValue.toStringRecord, bindings3->Reducer_Value.toStringRecord,
)->expect == ("Ok(())", "{z: 3}") )->expect == ("Ok(())", "{z: 3}")
}) })
@ -93,8 +92,8 @@ describe("ReducerProject Tutorial", () => {
let bindings3 = project->Project.getBindings("source3") let bindings3 = project->Project.getBindings("source3")
( (
result3->InternalExpressionValue.toStringResult, result3->Reducer_Value.toStringResult,
bindings3->InternalExpressionValue.toStringRecord, bindings3->Reducer_Value.toStringRecord,
)->expect == ("Ok(())", "{z: 3}") )->expect == ("Ok(())", "{z: 3}")
/* /*
Doing it like this is too verbose for a storybook Doing it like this is too verbose for a storybook

View File

@ -1,5 +1,4 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
@ -146,8 +145,8 @@ Here we will finally proceed to a real life scenario. */
/* And see the result and bindings.. */ /* And see the result and bindings.. */
test("recursive includes", () => { test("recursive includes", () => {
( (
result->InternalExpressionValue.toStringResult, result->Reducer_Value.toStringResult,
bindings->InternalExpressionValue.toStringRecord, bindings->Reducer_Value.toStringRecord,
)->expect == ("Ok(6)", "{a: 6,b: 2}") )->expect == ("Ok(6)", "{a: 6,b: 2}")
/* Everything as expected */ /* Everything as expected */
}) })

View File

@ -1,7 +1,5 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings
open Jest open Jest
open Expect open Expect
@ -30,7 +28,7 @@ describe("ReducerProject Tutorial", () => {
/* We can now run the project */ /* We can now run the project */
Project.runAll(project) Project.runAll(project)
let result = Project.getResult(project, "main") let result = Project.getResult(project, "main")
result->InternalExpressionValue.toStringResult->expect == "Ok(6)" result->Reducer_Value.toStringResult->expect == "Ok(6)"
}) })
}) })

View File

@ -1,5 +1,4 @@
@@warning("-44") @@warning("-44")
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Project = ForTS_ReducerProject module Project = ForTS_ReducerProject
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
@ -32,7 +31,7 @@ describe("ReducerProject Tutorial", () => {
test("userResults", () => { test("userResults", () => {
let userResultsAsString = Belt.Array.map(userResults, aResult => let userResultsAsString = Belt.Array.map(userResults, aResult =>
aResult->InternalExpressionValue.toStringResult aResult->Reducer_Value.toStringResult
) )
userResultsAsString->expect == ["Ok(2)", "Ok(4)", "Ok(6)", "Ok(8)", "Ok(10)"] userResultsAsString->expect == ["Ok(2)", "Ok(4)", "Ok(6)", "Ok(8)", "Ok(10)"]
}) })

View File

@ -4,7 +4,6 @@ open Reducer_TestHelpers
let expectEvalToBeOk = (code: string) => let expectEvalToBeOk = (code: string) =>
Reducer_Expression.BackCompatible.evaluateString(code) Reducer_Expression.BackCompatible.evaluateString(code)
->Reducer_Helpers.rRemoveDefaultsInternal
->E.R.isOk ->E.R.isOk
->expect ->expect
->toBe(true) ->toBe(true)
@ -102,7 +101,7 @@ describe("FunctionRegistry Library", () => {
let responseType = let responseType =
example example
->Reducer_Expression.BackCompatible.evaluateString ->Reducer_Expression.BackCompatible.evaluateString
->E.R2.fmap(ReducerInterface_InternalExpressionValue.valueToValueType) ->E.R2.fmap(Reducer_Value.valueToValueType)
let expectedOutputType = fn.output |> E.O.toExn("") let expectedOutputType = fn.output |> E.O.toExn("")
expect(responseType)->toEqual(Ok(expectedOutputType)) expect(responseType)->toEqual(Ok(expectedOutputType))
}, },

View File

@ -5,7 +5,7 @@ let nameSpace = "" // no namespaced versions
type simpleDefinition = { type simpleDefinition = {
inputs: array<frType>, inputs: array<frType>,
fn: array<internalExpressionValue> => result<internalExpressionValue, errorValue>, fn: array<Reducer_T.value> => result<Reducer_T.value, errorValue>,
} }
let makeFnMany = (name: string, definitions: array<simpleDefinition>) => let makeFnMany = (name: string, definitions: array<simpleDefinition>) =>
@ -22,7 +22,7 @@ let makeFnMany = (name: string, definitions: array<simpleDefinition>) =>
let makeFn = ( let makeFn = (
name: string, name: string,
inputs: array<frType>, inputs: array<frType>,
fn: array<internalExpressionValue> => result<internalExpressionValue, errorValue>, fn: array<Reducer_T.value> => result<Reducer_T.value, errorValue>,
) => makeFnMany(name, [{inputs: inputs, fn: fn}]) ) => makeFnMany(name, [{inputs: inputs, fn: fn}])
let library = [ let library = [
@ -140,7 +140,7 @@ let library = [
makeFn("inspect", [FRTypeAny], inputs => { makeFn("inspect", [FRTypeAny], inputs => {
switch inputs { switch inputs {
| [value] => { | [value] => {
Js.log(value->ReducerInterface_InternalExpressionValue.toString) Js.log(value->Reducer_Value.toString)
value->Ok value->Ok
} }
| _ => Error(impossibleError) | _ => Error(impossibleError)
@ -149,7 +149,7 @@ let library = [
makeFn("inspect", [FRTypeAny, FRTypeString], inputs => { makeFn("inspect", [FRTypeAny, FRTypeString], inputs => {
switch inputs { switch inputs {
| [value, IEvString(label)] => { | [value, IEvString(label)] => {
Js.log(`${label}: ${value->ReducerInterface_InternalExpressionValue.toString}`) Js.log(`${label}: ${value->Reducer_Value.toString}`)
value->Ok value->Ok
} }
| _ => Error(impossibleError) | _ => Error(impossibleError)
@ -158,7 +158,7 @@ let library = [
makeFn("javascriptraise", [FRTypeAny], inputs => { makeFn("javascriptraise", [FRTypeAny], inputs => {
switch inputs { switch inputs {
| [msg] => { | [msg] => {
Js.Exn.raiseError(msg->ReducerInterface_InternalExpressionValue.toString) Js.Exn.raiseError(msg->Reducer_Value.toString)
} }
| _ => Error(impossibleError) | _ => Error(impossibleError)
} }

View File

@ -4,7 +4,7 @@ open FunctionRegistry_Helpers
let makeFn = ( let makeFn = (
name: string, name: string,
inputs: array<frType>, inputs: array<frType>,
fn: array<internalExpressionValue> => result<internalExpressionValue, errorValue>, fn: array<Reducer_T.value> => result<Reducer_T.value, errorValue>,
) => ) =>
Function.make( Function.make(
~name, ~name,

View File

@ -6,24 +6,24 @@ let nameSpace = "Dict"
module Internals = { module Internals = {
type t = Reducer_T.map type t = Reducer_T.map
let keys = (a: t): internalExpressionValue => IEvArray( let keys = (a: t): Reducer_T.value => IEvArray(
Belt.Map.String.keysToArray(a)->E.A2.fmap(Wrappers.evString), Belt.Map.String.keysToArray(a)->E.A2.fmap(Wrappers.evString),
) )
let values = (a: t): internalExpressionValue => IEvArray(Belt.Map.String.valuesToArray(a)) let values = (a: t): Reducer_T.value => IEvArray(Belt.Map.String.valuesToArray(a))
let toList = (a: t): internalExpressionValue => let toList = (a: t): Reducer_T.value =>
Belt.Map.String.toArray(a) Belt.Map.String.toArray(a)
->E.A2.fmap(((key, value)) => Wrappers.evArray([IEvString(key), value])) ->E.A2.fmap(((key, value)) => Wrappers.evArray([IEvString(key), value]))
->Wrappers.evArray ->Wrappers.evArray
let fromList = (items: array<internalExpressionValue>): result< let fromList = (items: array<Reducer_T.value>): result<
internalExpressionValue, Reducer_T.value,
errorValue, errorValue,
> => > =>
items items
->E.A2.fmap(item => { ->E.A2.fmap(item => {
switch (item: internalExpressionValue) { switch (item: Reducer_T.value) {
| IEvArray([IEvString(string), value]) => (string, value)->Ok | IEvArray([IEvString(string), value]) => (string, value)->Ok
| _ => Error(impossibleError) | _ => Error(impossibleError)
} }
@ -32,12 +32,12 @@ module Internals = {
->E.R2.fmap(Belt.Map.String.fromArray) ->E.R2.fmap(Belt.Map.String.fromArray)
->E.R2.fmap(Wrappers.evRecord) ->E.R2.fmap(Wrappers.evRecord)
let merge = (a: t, b: t): internalExpressionValue => IEvRecord( let merge = (a: t, b: t): Reducer_T.value => IEvRecord(
Belt.Map.String.merge(a, b, (_, _, c) => c), Belt.Map.String.merge(a, b, (_, _, c) => c),
) )
//Belt.Map.String has a function for mergeMany, but I couldn't understand how to use it yet. //Belt.Map.String has a function for mergeMany, but I couldn't understand how to use it yet.
let mergeMany = (a: array<t>): internalExpressionValue => { let mergeMany = (a: array<t>): Reducer_T.value => {
let mergedValues = let mergedValues =
a->E.A2.fmap(Belt.Map.String.toArray)->Belt.Array.concatMany->Belt.Map.String.fromArray a->E.A2.fmap(Belt.Map.String.toArray)->Belt.Array.concatMany->Belt.Map.String.fromArray
IEvRecord(mergedValues) IEvRecord(mergedValues)

View File

@ -4,7 +4,7 @@ let twoArgs = E.Tuple2.toFnCall
module DistributionCreation = { module DistributionCreation = {
let nameSpace = "Dist" let nameSpace = "Dist"
let output = ReducerInterface_InternalExpressionValue.EvtDistribution let output = Reducer_Value.EvtDistribution
let requiresNamespace = false let requiresNamespace = false
let fnMake = (~name, ~examples, ~definitions) => { let fnMake = (~name, ~examples, ~definitions) => {

View File

@ -7,7 +7,7 @@ module Declaration = {
("inputs", FRTypeArray(FRTypeRecord([("min", FRTypeNumber), ("max", FRTypeNumber)]))), ("inputs", FRTypeArray(FRTypeRecord([("min", FRTypeNumber), ("max", FRTypeNumber)]))),
]) ])
let fromExpressionValue = (e: frValue): result<internalExpressionValue, string> => { let fromExpressionValue = (e: frValue): result<Reducer_T.value, string> => {
switch FunctionRegistry_Helpers.Prepare.ToValueArray.Record.twoArgs([e]) { switch FunctionRegistry_Helpers.Prepare.ToValueArray.Record.twoArgs([e]) {
| Ok([FRValueLambda(lambda), FRValueArray(inputs)]) => { | Ok([FRValueLambda(lambda), FRValueArray(inputs)]) => {
open FunctionRegistry_Helpers.Prepare open FunctionRegistry_Helpers.Prepare

View File

@ -18,7 +18,7 @@ module Old = {
| _ => #Multiply | _ => #Multiply
} }
let catchAndConvertTwoArgsToDists = (args: array<internalExpressionValue>): option<( let catchAndConvertTwoArgsToDists = (args: array<Reducer_T.value>): option<(
DistributionTypes.genericDist, DistributionTypes.genericDist,
DistributionTypes.genericDist, DistributionTypes.genericDist,
)> => )> =>
@ -68,18 +68,18 @@ module Old = {
)->DistributionOperation.run(~env) )->DistributionOperation.run(~env)
} }
let parseNumber = (args: internalExpressionValue): Belt.Result.t<float, string> => let parseNumber = (args: Reducer_T.value): Belt.Result.t<float, string> =>
switch args { switch args {
| IEvNumber(x) => Ok(x) | IEvNumber(x) => Ok(x)
| _ => Error("Not a number") | _ => Error("Not a number")
} }
let parseNumberArray = (ags: array<internalExpressionValue>): Belt.Result.t< let parseNumberArray = (ags: array<Reducer_T.value>): Belt.Result.t<
array<float>, array<float>,
string, string,
> => E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen > => E.A.fmap(parseNumber, ags) |> E.A.R.firstErrorOrOpen
let parseDist = (args: internalExpressionValue): Belt.Result.t< let parseDist = (args: Reducer_T.value): Belt.Result.t<
DistributionTypes.genericDist, DistributionTypes.genericDist,
string, string,
> => > =>
@ -89,7 +89,7 @@ module Old = {
| _ => Error("Not a distribution") | _ => Error("Not a distribution")
} }
let parseDistributionArray = (ags: array<internalExpressionValue>): Belt.Result.t< let parseDistributionArray = (ags: array<Reducer_T.value>): Belt.Result.t<
array<DistributionTypes.genericDist>, array<DistributionTypes.genericDist>,
string, string,
> => E.A.fmap(parseDist, ags) |> E.A.R.firstErrorOrOpen > => E.A.fmap(parseDist, ags) |> E.A.R.firstErrorOrOpen
@ -115,7 +115,7 @@ module Old = {
} }
let mixture = ( let mixture = (
args: array<internalExpressionValue>, args: array<Reducer_T.value>,
~env: GenericDist.env, ~env: GenericDist.env,
): DistributionOperation.outputType => { ): DistributionOperation.outputType => {
let error = (err: string): DistributionOperation.outputType => let error = (err: string): DistributionOperation.outputType =>
@ -174,7 +174,7 @@ module Old = {
} }
let dispatchToGenericOutput = ( let dispatchToGenericOutput = (
call: ReducerInterface_InternalExpressionValue.functionCall, call: Reducer_Value.functionCall,
env: GenericDist.env, env: GenericDist.env,
): option<DistributionOperation.outputType> => { ): option<DistributionOperation.outputType> => {
let (fnName, args) = call let (fnName, args) = call
@ -301,7 +301,7 @@ module Old = {
} }
let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< let genericOutputToReducerValue = (o: DistributionOperation.outputType): result<
internalExpressionValue, Reducer_T.value,
Reducer_ErrorValue.errorValue, Reducer_ErrorValue.errorValue,
> => > =>
switch o { switch o {
@ -313,7 +313,7 @@ module Old = {
| GenDistError(err) => Error(REDistributionError(err)) | GenDistError(err) => Error(REDistributionError(err))
} }
let dispatch = (call: ReducerInterface_InternalExpressionValue.functionCall, environment) => let dispatch = (call: Reducer_Value.functionCall, environment) =>
switch dispatchToGenericOutput(call, environment) { switch dispatchToGenericOutput(call, environment) {
| Some(o) => genericOutputToReducerValue(o) | Some(o) => genericOutputToReducerValue(o)
| None => | None =>

View File

@ -7,29 +7,29 @@ let requiresNamespace = true
module Internals = { module Internals = {
let makeFromNumber = ( let makeFromNumber = (
n: float, n: float,
value: internalExpressionValue, value: Reducer_T.value,
): internalExpressionValue => IEvArray(Belt.Array.make(E.Float.toInt(n), value)) ): Reducer_T.value => IEvArray(Belt.Array.make(E.Float.toInt(n), value))
let upTo = (low: float, high: float): internalExpressionValue => IEvArray( let upTo = (low: float, high: float): Reducer_T.value => IEvArray(
E.A.Floats.range(low, high, (high -. low +. 1.0)->E.Float.toInt)->E.A2.fmap(Wrappers.evNumber), E.A.Floats.range(low, high, (high -. low +. 1.0)->E.Float.toInt)->E.A2.fmap(Wrappers.evNumber),
) )
let first = (v: array<internalExpressionValue>): result<internalExpressionValue, string> => let first = (v: array<Reducer_T.value>): result<Reducer_T.value, string> =>
v->E.A.first |> E.O.toResult("No first element") v->E.A.first |> E.O.toResult("No first element")
let last = (v: array<internalExpressionValue>): result<internalExpressionValue, string> => let last = (v: array<Reducer_T.value>): result<Reducer_T.value, string> =>
v->E.A.last |> E.O.toResult("No last element") v->E.A.last |> E.O.toResult("No last element")
let reverse = (array: array<internalExpressionValue>): internalExpressionValue => IEvArray( let reverse = (array: array<Reducer_T.value>): Reducer_T.value => IEvArray(
Belt.Array.reverse(array), Belt.Array.reverse(array),
) )
let map = ( let map = (
array: array<internalExpressionValue>, array: array<Reducer_T.value>,
eLambdaValue, eLambdaValue,
env: Reducer_T.environment, env: Reducer_T.environment,
reducer: Reducer_T.reducerFn, reducer: Reducer_T.reducerFn,
): internalExpressionValue => { ): Reducer_T.value => {
Belt.Array.map(array, elem => Belt.Array.map(array, elem =>
Reducer_Expression_Lambda.doLambdaCall(eLambdaValue, [elem], env, reducer) Reducer_Expression_Lambda.doLambdaCall(eLambdaValue, [elem], env, reducer)
)->Wrappers.evArray )->Wrappers.evArray

View File

@ -48,7 +48,7 @@ let library = [
~nameSpace, ~nameSpace,
~requiresNamespace=true, ~requiresNamespace=true,
~examples=[`PointSet.fromDist(normal(5,2))`], ~examples=[`PointSet.fromDist(normal(5,2))`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="fromDist", ~name="fromDist",
@ -77,7 +77,7 @@ let library = [
~nameSpace, ~nameSpace,
~requiresNamespace=true, ~requiresNamespace=true,
~examples=[`PointSet.mapY(mx(normal(5,2)), {|x| x + 1})`], ~examples=[`PointSet.mapY(mx(normal(5,2)), {|x| x + 1})`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="mapY", ~name="mapY",
@ -105,7 +105,7 @@ let library = [
{x: 3, y: 0.2} {x: 3, y: 0.2}
])`, ])`,
], ],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="makeContinuous", ~name="makeContinuous",
@ -129,7 +129,7 @@ let library = [
{x: 3, y: 0.2} {x: 3, y: 0.2}
])`, ])`,
], ],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="makeDiscrete", ~name="makeDiscrete",

View File

@ -48,10 +48,10 @@ module Internal = {
SampleSetDist.map3(~fn, ~t1, ~t2, ~t3)->toType SampleSetDist.map3(~fn, ~t1, ~t2, ~t3)->toType
} }
let parseSampleSetArray = (arr: array<internalExpressionValue>): option< let parseSampleSetArray = (arr: array<Reducer_T.value>): option<
array<SampleSetDist.t>, array<SampleSetDist.t>,
> => { > => {
let parseSampleSet = (value: internalExpressionValue): option<SampleSetDist.t> => let parseSampleSet = (value: Reducer_T.value): option<SampleSetDist.t> =>
switch value { switch value {
| IEvDistribution(SampleSet(dist)) => Some(dist) | IEvDistribution(SampleSet(dist)) => Some(dist)
| _ => None | _ => None
@ -60,7 +60,7 @@ module Internal = {
} }
let mapN = ( let mapN = (
aValueArray: array<internalExpressionValue>, aValueArray: array<Reducer_T.value>,
aLambdaValue, aLambdaValue,
environment: Reducer_T.environment, environment: Reducer_T.environment,
reducer, reducer,
@ -86,7 +86,7 @@ let libaryBase = [
~nameSpace, ~nameSpace,
~requiresNamespace=true, ~requiresNamespace=true,
~examples=[`SampleSet.fromDist(normal(5,2))`], ~examples=[`SampleSet.fromDist(normal(5,2))`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="fromDist", ~name="fromDist",
@ -110,7 +110,7 @@ let libaryBase = [
~nameSpace, ~nameSpace,
~requiresNamespace=true, ~requiresNamespace=true,
~examples=[`SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])`], ~examples=[`SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="fromList", ~name="fromList",
@ -135,7 +135,7 @@ let libaryBase = [
~nameSpace, ~nameSpace,
~requiresNamespace=true, ~requiresNamespace=true,
~examples=[`SampleSet.toList(SampleSet.fromDist(normal(5,2)))`], ~examples=[`SampleSet.toList(SampleSet.fromDist(normal(5,2)))`],
~output=ReducerInterface_InternalExpressionValue.EvtArray, ~output=Reducer_Value.EvtArray,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="toList", ~name="toList",
@ -156,7 +156,7 @@ let libaryBase = [
~nameSpace, ~nameSpace,
~requiresNamespace=true, ~requiresNamespace=true,
~examples=[`SampleSet.fromFn({|| sample(normal(5,2))})`], ~examples=[`SampleSet.fromFn({|| sample(normal(5,2))})`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="fromFn", ~name="fromFn",
@ -180,7 +180,7 @@ let libaryBase = [
~nameSpace, ~nameSpace,
~requiresNamespace, ~requiresNamespace,
~examples=[`SampleSet.map(SampleSet.fromDist(normal(5,2)), {|x| x + 1})`], ~examples=[`SampleSet.map(SampleSet.fromDist(normal(5,2)), {|x| x + 1})`],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="map", ~name="map",
@ -203,7 +203,7 @@ let libaryBase = [
~examples=[ ~examples=[
`SampleSet.map2(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y| x + y})`, `SampleSet.map2(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y| x + y})`,
], ],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="map2", ~name="map2",
@ -231,7 +231,7 @@ let libaryBase = [
~examples=[ ~examples=[
`SampleSet.map3(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y, z| max([x,y,z])})`, `SampleSet.map3(SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y, z| max([x,y,z])})`,
], ],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="map3", ~name="map3",
@ -259,7 +259,7 @@ let libaryBase = [
~examples=[ ~examples=[
`SampleSet.mapN([SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2))], {|x| max(x)})`, `SampleSet.mapN([SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2))], {|x| max(x)})`,
], ],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
FnDefinition.make( FnDefinition.make(
~name="mapN", ~name="mapN",
@ -306,7 +306,7 @@ module Comparison = {
`SampleSet.${name}(SampleSet.fromDist(normal(5,2)), 3.0)`, `SampleSet.${name}(SampleSet.fromDist(normal(5,2)), 3.0)`,
`SampleSet.${name}(4.0, SampleSet.fromDist(normal(6,2)))`, `SampleSet.${name}(4.0, SampleSet.fromDist(normal(6,2)))`,
], ],
~output=ReducerInterface_InternalExpressionValue.EvtDistribution, ~output=Reducer_Value.EvtDistribution,
~definitions=[ ~definitions=[
template(name, [FRTypeDist, FRTypeDist], inputs => { template(name, [FRTypeDist, FRTypeDist], inputs => {
switch inputs { switch inputs {

View File

@ -8,7 +8,7 @@
type environment = ForTS_Distribution_Environment.environment //use type environment = ForTS_Distribution_Environment.environment //use
@genType @genType
let defaultEnvironment: environment = DistributionOperation.defaultEnv let defaultEnvironment: environment = Reducer_Context.defaultEnvironment
@module("./ForTS_Distribution_tag") @scope("distributionTag") @module("./ForTS_Distribution_tag") @scope("distributionTag")
external dtPointSet_: string = "PointSet" external dtPointSet_: string = "PointSet"

View File

@ -74,13 +74,13 @@ let getTag = (variant: squiggleValue): squiggleValueTag =>
@genType @genType
let toString = (variant: squiggleValue) => let toString = (variant: squiggleValue) =>
ReducerInterface_InternalExpressionValue.toString(variant) Reducer_Value.toString(variant)
// This is a useful method for unit tests. // This is a useful method for unit tests.
// Convert the result along with the error message to a string. // Convert the result along with the error message to a string.
@genType @genType
let toStringResult = (variantResult: result<squiggleValue, reducerErrorValue>) => let toStringResult = (variantResult: result<squiggleValue, reducerErrorValue>) =>
ReducerInterface_InternalExpressionValue.toStringResult(variantResult) Reducer_Value.toStringResult(variantResult)
@genType @genType
let getArray = (variant: squiggleValue): option<squiggleValue_Array> => let getArray = (variant: squiggleValue): option<squiggleValue_Array> =>

View File

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

View File

@ -2,4 +2,4 @@
@genType @genType
let toString = (v: squiggleValue_Declaration): string => let toString = (v: squiggleValue_Declaration): string =>
ReducerInterface_InternalExpressionValue.toStringDeclaration(v) Reducer_Value.toStringDeclaration(v)

View File

@ -2,4 +2,4 @@
@genType @genType
let toString = (v: squiggleValue_Distribution): string => let toString = (v: squiggleValue_Distribution): string =>
ReducerInterface_InternalExpressionValue.toStringDistribution(v) Reducer_Value.toStringDistribution(v)

View File

@ -2,7 +2,7 @@
@genType @genType
let toString = (v: squiggleValue_Lambda): string => let toString = (v: squiggleValue_Lambda): string =>
ReducerInterface_InternalExpressionValue.toStringFunction(v) Reducer_Value.toStringFunction(v)
@genType @genType
let parameters = (v: squiggleValue_Lambda): array<string> => { let parameters = (v: squiggleValue_Lambda): array<string> => {

View File

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

View File

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

View File

@ -1,5 +1,4 @@
type internalExpressionValue = Reducer_T.value type internalExpressionValueType = Reducer_Value.internalExpressionValueType
type internalExpressionValueType = ReducerInterface_InternalExpressionValue.internalExpressionValueType
type errorValue = Reducer_ErrorValue.errorValue type errorValue = Reducer_ErrorValue.errorValue
/* /*
@ -51,11 +50,11 @@ type fnDefinition = {
name: string, name: string,
inputs: array<frType>, inputs: array<frType>,
run: ( run: (
array<internalExpressionValue>, array<Reducer_T.value>,
array<frValue>, array<frValue>,
Reducer_T.environment, Reducer_T.environment,
Reducer_T.reducerFn, Reducer_T.reducerFn,
) => result<internalExpressionValue, errorValue>, ) => result<Reducer_T.value, errorValue>,
} }
type function = { type function = {
@ -92,7 +91,7 @@ module FRType = {
| FRTypeAny => `any` | FRTypeAny => `any`
} }
let rec toFrValue = (r: internalExpressionValue): option<frValue> => let rec toFrValue = (r: Reducer_T.value): option<frValue> =>
// not all value variants are supported, but it's not important (we'll probably deprecate frValues soon anyway) // not all value variants are supported, but it's not important (we'll probably deprecate frValues soon anyway)
switch r { switch r {
| IEvNumber(f) => Some(FRValueNumber(f)) | IEvNumber(f) => Some(FRValueNumber(f))
@ -109,7 +108,7 @@ module FRType = {
| _ => None | _ => None
} }
let rec matchWithExpressionValue = (t: t, r: internalExpressionValue): option<frValue> => let rec matchWithExpressionValue = (t: t, r: Reducer_T.value): option<frValue> =>
switch (t, r) { switch (t, r) {
| (FRTypeAny, f) => toFrValue(f) | (FRTypeAny, f) => toFrValue(f)
| (FRTypeString, IEvString(f)) => Some(FRValueString(f)) | (FRTypeString, IEvString(f)) => Some(FRValueString(f))
@ -149,7 +148,7 @@ module FRType = {
| _ => None | _ => None
} }
let rec matchReverse = (e: frValue): internalExpressionValue => let rec matchReverse = (e: frValue): Reducer_T.value =>
switch e { switch e {
| FRValueNumber(f) => IEvNumber(f) | FRValueNumber(f) => IEvNumber(f)
| FRValueBool(f) => IEvBool(f) | FRValueBool(f) => IEvBool(f)
@ -182,7 +181,7 @@ module FRType = {
let matchWithExpressionValueArray = ( let matchWithExpressionValueArray = (
inputs: array<t>, inputs: array<t>,
args: array<internalExpressionValue>, args: array<Reducer_T.value>,
): option<array<frValue>> => { ): option<array<frValue>> => {
let isSameLength = E.A.length(inputs) == E.A.length(args) let isSameLength = E.A.length(inputs) == E.A.length(args)
if !isSameLength { if !isSameLength {
@ -203,7 +202,7 @@ module FnDefinition = {
t.name ++ `(${inputs})` t.name ++ `(${inputs})`
} }
let isMatch = (t: t, args: array<internalExpressionValue>) => { let isMatch = (t: t, args: array<Reducer_T.value>) => {
let argValues = FRType.matchWithExpressionValueArray(t.inputs, args) let argValues = FRType.matchWithExpressionValueArray(t.inputs, args)
switch argValues { switch argValues {
| Some(_) => true | Some(_) => true
@ -213,7 +212,7 @@ module FnDefinition = {
let run = ( let run = (
t: t, t: t,
args: array<internalExpressionValue>, args: array<Reducer_T.value>,
env: Reducer_T.environment, env: Reducer_T.environment,
reducer: Reducer_T.reducerFn, reducer: Reducer_T.reducerFn,
) => { ) => {
@ -317,10 +316,10 @@ module Registry = {
let call = ( let call = (
registry, registry,
fnName: string, fnName: string,
args: array<internalExpressionValue>, args: array<Reducer_T.value>,
env: Reducer_T.environment, env: Reducer_T.environment,
reducer: Reducer_T.reducerFn, reducer: Reducer_T.reducerFn,
): result<internalExpressionValue, errorValue> => { ): result<Reducer_T.value, errorValue> => {
switch Belt.Map.String.get(registry.fnNameDict, fnName) { switch Belt.Map.String.get(registry.fnNameDict, fnName) {
| Some(definitions) => { | Some(definitions) => {
let showNameMatchDefinitions = () => { let showNameMatchDefinitions = () => {

View File

@ -5,7 +5,6 @@
*/ */
type t = Reducer_T.bindings type t = Reducer_T.bindings
type internalExpressionValue = Reducer_T.value
let rec get = ({namespace, parent}: t, id: string) => { let rec get = ({namespace, parent}: t, id: string) => {
switch namespace->Reducer_Namespace.get(id) { switch namespace->Reducer_Namespace.get(id) {

View File

@ -1,5 +1,7 @@
type t = Reducer_T.context type t = Reducer_T.context
let defaultEnvironment: Reducer_T.environment = DistributionOperation.defaultEnv
let createContext = (stdLib: Reducer_Namespace.t, environment: Reducer_T.environment): t => { let createContext = (stdLib: Reducer_Namespace.t, environment: Reducer_T.environment): t => {
{ {
bindings: stdLib->Reducer_Bindings.fromNamespace->Reducer_Bindings.extend, bindings: stdLib->Reducer_Bindings.fromNamespace->Reducer_Bindings.extend,
@ -8,7 +10,4 @@ let createContext = (stdLib: Reducer_Namespace.t, environment: Reducer_T.environ
} }
let createDefaultContext = (): t => let createDefaultContext = (): t =>
createContext( createContext(SquiggleLibrary_StdLib.stdLib, defaultEnvironment)
ReducerInterface_StdLib.internalStdLib,
ReducerInterface_InternalExpressionValue.defaultEnvironment,
)

View File

@ -1,7 +1,7 @@
// module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
// module T = Reducer_Dispatch_T // module T = Reducer_Dispatch_T
// module TypeChecker = Reducer_Type_TypeChecker // module TypeChecker = Reducer_Type_TypeChecker
// open ReducerInterface_InternalExpressionValue // open Reducer_Value
// type errorValue = Reducer_ErrorValue.errorValue // type errorValue = Reducer_ErrorValue.errorValue

View File

@ -1,15 +1,14 @@
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// module ExpressionT = Reducer_Expression_T // module ExpressionT = Reducer_Expression_T
// module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
// // Each piece of the dispatch chain computes the result or returns None so that the chain can continue // // Each piece of the dispatch chain computes the result or returns None so that the chain can continue
// type dispatchChainPiece = ( // type dispatchChainPiece = (
// InternalExpressionValue.functionCall, // Reducer_Value.functionCall,
// ProjectAccessorsT.t, // ProjectAccessorsT.t,
// ) => option<result<Reducer_T.value, Reducer_ErrorValue.errorValue>> // ) => option<result<Reducer_T.value, Reducer_ErrorValue.errorValue>>
// type dispatchChainPieceWithReducer = ( // type dispatchChainPieceWithReducer = (
// InternalExpressionValue.functionCall, // Reducer_Value.functionCall,
// ProjectAccessorsT.t, // ProjectAccessorsT.t,
// Reducer_T.reducerFn, // Reducer_T.reducerFn,
// ) => option<result<Reducer_T.value, Reducer_ErrorValue.errorValue>> // ) => option<result<Reducer_T.value, Reducer_ErrorValue.errorValue>>

View File

@ -103,7 +103,7 @@ let rec evaluate: T.reducerFn = (expression, context): (T.value, T.context) => {
context, context,
) )
| _ => | _ =>
RENotAFunction(lambda->ReducerInterface_InternalExpressionValue.toString) RENotAFunction(lambda->Reducer_Value.toString)
->Reducer_ErrorValue.ErrorException ->Reducer_ErrorValue.ErrorException
->raise ->raise
} }

View File

@ -1,8 +1,5 @@
module Bindings = Reducer_Bindings
module ErrorValue = Reducer_ErrorValue module ErrorValue = Reducer_ErrorValue
type internalExpressionValue = ReducerInterface_InternalExpressionValue.t
let doLambdaCall = ( let doLambdaCall = (
lambdaValue: Reducer_T.lambdaValue, lambdaValue: Reducer_T.lambdaValue,
args, args,
@ -21,6 +18,7 @@ let makeLambda = (
// Note: with this implementation, FFI lambdas (created by other methods than calling `makeLambda`) are allowed to violate the rules, pollute the bindings, etc. // Note: with this implementation, FFI lambdas (created by other methods than calling `makeLambda`) are allowed to violate the rules, pollute the bindings, etc.
// Not sure yet if that's a bug or a feature. // Not sure yet if that's a bug or a feature.
// FunctionRegistry functions are unaffected by this, their API is too limited.
let lambda = ( let lambda = (
arguments: array<Reducer_T.value>, arguments: array<Reducer_T.value>,

View File

@ -2,8 +2,6 @@
An expression is an intermediate representation of a Squiggle code. An expression is an intermediate representation of a Squiggle code.
Expressions are evaluated by `Reducer_Expression.evaluate` function. Expressions are evaluated by `Reducer_Expression.evaluate` function.
*/ */
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
type t = Reducer_T.expression type t = Reducer_T.expression
let commaJoin = values => values->Reducer_Extra_Array.intersperse(", ")->Js.String.concatMany("") let commaJoin = values => values->Reducer_Extra_Array.intersperse(", ")->Js.String.concatMany("")
@ -27,7 +25,7 @@ let rec toString = (expression: t) =>
| EAssign(name, value) => `${name} = ${value->toString}` | EAssign(name, value) => `${name} = ${value->toString}`
| ECall(fn, args) => `(${fn->toString})(${args->Js.Array2.map(toString)->commaJoin})` | ECall(fn, args) => `(${fn->toString})(${args->Js.Array2.map(toString)->commaJoin})`
| ELambda(parameters, body) => `{|${parameters->commaJoin}| ${body->toString}}` | ELambda(parameters, body) => `{|${parameters->commaJoin}| ${body->toString}}`
| EValue(aValue) => InternalExpressionValue.toString(aValue) | EValue(aValue) => Reducer_Value.toString(aValue)
} }
let toStringResult = codeResult => let toStringResult = codeResult =>

View File

@ -1 +0,0 @@
module Gate = Reducer_Js_Gate

View File

@ -1,17 +0,0 @@
open ReducerInterface_InternalExpressionValue
open Reducer_ErrorValue
external castBool: unit => bool = "%identity"
external castNumber: unit => float = "%identity"
external castString: unit => string = "%identity"
/*
As JavaScript returns us any type, we need to type check and cast type propertype before using it
*/
let jsToIEv = (jsValue): result<internalExpressionValue, errorValue> =>
switch Js.typeof(jsValue) {
| "boolean" => jsValue->castBool->IEvBool->Ok
| "number" => jsValue->castNumber->IEvNumber->Ok
| "string" => jsValue->castString->IEvString->Ok
| other => RETodo(`Unhandled MathJs literal type: ${Js.String.make(other)}`)->Error
}

View File

@ -25,7 +25,7 @@ let toString = (namespace: t) =>
namespace namespace
->Belt.Map.String.toArray ->Belt.Map.String.toArray
->Belt.Array.map(((eachKey, eachValue)) => ->Belt.Array.map(((eachKey, eachValue)) =>
`${eachKey}: ${eachValue->ReducerInterface_InternalExpressionValue.toString}` `${eachKey}: ${eachValue->Reducer_Value.toString}`
) )
->Js.Array2.toString ->Js.Array2.toString

View File

@ -1,15 +1,12 @@
// module Bindings = Reducer_Bindings // module Bindings = Reducer_Bindings
// module ErrorValue = Reducer_ErrorValue // module ErrorValue = Reducer_ErrorValue
// module Expression = Reducer_Expression
// module ExpressionT = Reducer_Expression_T
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
// module T = Reducer_Type_T // module T = Reducer_Type_T
// let ievFromTypeExpression = ( // let ievFromTypeExpression = (
// typeExpressionSourceCode: string, // typeExpressionSourceCode: string,
// reducerFn: ProjectReducerFnT.t, // reducerFn: ProjectReducerFnT.t,
// ): result<InternalExpressionValue.t, ErrorValue.t> => { // ): result<Reducer_Value.t, ErrorValue.t> => {
// let sIndex = "compiled" // let sIndex = "compiled"
// let sourceCode = `type ${sIndex}=${typeExpressionSourceCode}` // let sourceCode = `type ${sIndex}=${typeExpressionSourceCode}`
// Reducer_Expression.BackCompatible.parse(sourceCode)->Belt.Result.flatMap(expr => { // Reducer_Expression.BackCompatible.parse(sourceCode)->Belt.Result.flatMap(expr => {

View File

@ -1,7 +1,6 @@
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module T = Reducer_Type_T module T = Reducer_Type_T
let isMin = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionValue.t): bool => { let isMin = (modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => {
let pair = (modifierArg, aValue) let pair = (modifierArg, aValue)
switch pair { switch pair {
| (IEvNumber(a), IEvNumber(b)) => a <= b | (IEvNumber(a), IEvNumber(b)) => a <= b
@ -9,7 +8,7 @@ let isMin = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionV
} }
} }
let isMax = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionValue.t): bool => { let isMax = (modifierArg: Reducer_Value.t, aValue: Reducer_Value.t): bool => {
let pair = (modifierArg, aValue) let pair = (modifierArg, aValue)
switch pair { switch pair {
| (IEvNumber(a), IEvNumber(b)) => a >= b | (IEvNumber(a), IEvNumber(b)) => a >= b
@ -18,8 +17,8 @@ let isMax = (modifierArg: InternalExpressionValue.t, aValue: InternalExpressionV
} }
let isMemberOf = ( let isMemberOf = (
modifierArg: InternalExpressionValue.t, modifierArg: Reducer_Value.t,
aValue: InternalExpressionValue.t, aValue: Reducer_Value.t,
): bool => { ): bool => {
let pair = (modifierArg, aValue) let pair = (modifierArg, aValue)
switch pair { switch pair {
@ -30,8 +29,8 @@ let isMemberOf = (
let checkModifier = ( let checkModifier = (
key: string, key: string,
modifierArg: InternalExpressionValue.t, modifierArg: Reducer_Value.t,
aValue: InternalExpressionValue.t, aValue: Reducer_Value.t,
): bool => ): bool =>
switch key { switch key {
| "min" => isMin(modifierArg, aValue) | "min" => isMin(modifierArg, aValue)
@ -41,8 +40,8 @@ let checkModifier = (
} }
let checkModifiers = ( let checkModifiers = (
contracts: Belt.Map.String.t<InternalExpressionValue.t>, contracts: Belt.Map.String.t<Reducer_Value.t>,
aValue: InternalExpressionValue.t, aValue: Reducer_Value.t,
): bool => { ): bool => {
contracts->Belt.Map.String.reduce(true, (acc, key, modifierArg) => contracts->Belt.Map.String.reduce(true, (acc, key, modifierArg) =>
switch acc { switch acc {

View File

@ -1,9 +1,6 @@
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// open InternalExpressionValue
// type rec iType = // type rec iType =
// | ItTypeIdentifier(string) // | ItTypeIdentifier(string)
// | ItModifiedType({modifiedType: iType, contracts: Belt.Map.String.t<InternalExpressionValue.t>}) // | ItModifiedType({modifiedType: iType, contracts: Belt.Map.String.t<Reducer_Value.t>})
// | ItTypeOr({typeOr: array<iType>}) // | ItTypeOr({typeOr: array<iType>})
// | ItTypeFunction({inputs: array<iType>, output: iType}) // | ItTypeFunction({inputs: array<iType>, output: iType})
// | ItTypeArray({element: iType}) // | ItTypeArray({element: iType})
@ -11,14 +8,14 @@
// | ItTypeRecord({properties: Belt.Map.String.t<iType>}) // | ItTypeRecord({properties: Belt.Map.String.t<iType>})
// type t = iType // type t = iType
// type typeErrorValue = TypeMismatch(t, InternalExpressionValue.t) // type typeErrorValue = TypeMismatch(t, Reducer_Value.t)
// let rec toString = (t: t): string => { // let rec toString = (t: t): string => {
// switch t { // switch t {
// | ItTypeIdentifier(s) => s // | ItTypeIdentifier(s) => s
// | ItModifiedType({modifiedType, contracts}) => // | ItModifiedType({modifiedType, contracts}) =>
// `${toString(modifiedType)}${contracts->Belt.Map.String.reduce("", (acc, k, v) => // `${toString(modifiedType)}${contracts->Belt.Map.String.reduce("", (acc, k, v) =>
// Js.String2.concatMany(acc, ["<-", k, "(", InternalExpressionValue.toString(v), ")"]) // Js.String2.concatMany(acc, ["<-", k, "(", Reducer_Value.toString(v), ")"])
// )}` // )}`
// | ItTypeOr({typeOr}) => `(${Js.Array2.map(typeOr, toString)->Js.Array2.joinWith(" | ")})` // | ItTypeOr({typeOr}) => `(${Js.Array2.map(typeOr, toString)->Js.Array2.joinWith(" | ")})`
// | ItTypeFunction({inputs, output}) => // | ItTypeFunction({inputs, output}) =>
@ -41,42 +38,42 @@
// let rec fromTypeMap = typeMap => { // let rec fromTypeMap = typeMap => {
// let default = IEvString("") // let default = IEvString("")
// let evTypeTag: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evTypeTag: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "typeTag", // "typeTag",
// default, // default,
// ) // )
// let evTypeIdentifier: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evTypeIdentifier: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "typeIdentifier", // "typeIdentifier",
// default, // default,
// ) // )
// let evTypeOr: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evTypeOr: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "typeOr", // "typeOr",
// default, // default,
// ) // )
// let evInputs: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evInputs: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "inputs", // "inputs",
// default, // default,
// ) // )
// let evOutput: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evOutput: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "output", // "output",
// default, // default,
// ) // )
// let evElement: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evElement: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "element", // "element",
// default, // default,
// ) // )
// let evElements: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evElements: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "elements", // "elements",
// default, // default,
// ) // )
// let evProperties: InternalExpressionValue.t = Belt.Map.String.getWithDefault( // let evProperties: Reducer_Value.t = Belt.Map.String.getWithDefault(
// typeMap, // typeMap,
// "properties", // "properties",
// default, // default,
@ -101,18 +98,18 @@
// : ItModifiedType({modifiedType: makeIt, contracts: contracts}) // : ItModifiedType({modifiedType: makeIt, contracts: contracts})
// } // }
// and fromIEvValue = (ievValue: InternalExpressionValue.t): iType => // and fromIEvValue = (ievValue: Reducer_Value.t): iType =>
// switch ievValue { // switch ievValue {
// | IEvTypeIdentifier(typeIdentifier) => ItTypeIdentifier({typeIdentifier}) // | IEvTypeIdentifier(typeIdentifier) => ItTypeIdentifier({typeIdentifier})
// | IEvType(typeMap) => fromTypeMap(typeMap) // | IEvType(typeMap) => fromTypeMap(typeMap)
// | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievValue")) // | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievValue"))
// } // }
// and fromIEvArray = (ievArray: InternalExpressionValue.t) => // and fromIEvArray = (ievArray: Reducer_Value.t) =>
// switch ievArray { // switch ievArray {
// | IEvArray(array) => array->Belt.Array.map(fromIEvValue) // | IEvArray(array) => array->Belt.Array.map(fromIEvValue)
// | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievArray")) // | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievArray"))
// } // }
// and fromIEvRecord = (ievRecord: InternalExpressionValue.t) => // and fromIEvRecord = (ievRecord: Reducer_Value.t) =>
// switch ievRecord { // switch ievRecord {
// | IEvRecord(record) => record->Belt.Map.String.map(fromIEvValue) // | IEvRecord(record) => record->Belt.Map.String.map(fromIEvValue)
// | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievRecord")) // | _ => raise(Reducer_Exception.ImpossibleException("Reducer_Type_T-ievRecord"))

View File

@ -1,9 +1,8 @@
// module ExpressionT = Reducer_Expression_T // module ExpressionT = Reducer_Expression_T
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// module ProjectAccessorsT = ReducerProject_ProjectAccessors_T // module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
// module T = Reducer_Type_T // module T = Reducer_Type_T
// module TypeContracts = Reducer_Type_Contracts // module TypeContracts = Reducer_Type_Contracts
// open InternalExpressionValue // open Reducer_Value
// let rec isITypeOf = (anIType: T.iType, aValue): result<bool, T.typeErrorValue> => { // let rec isITypeOf = (anIType: T.iType, aValue): result<bool, T.typeErrorValue> => {
// let caseTypeIdentifier = (anUpperTypeName, aValue) => { // let caseTypeIdentifier = (anUpperTypeName, aValue) => {
@ -98,8 +97,8 @@
// let caseModifiedType = ( // let caseModifiedType = (
// anIType: T.iType, // anIType: T.iType,
// modifiedType: T.iType, // modifiedType: T.iType,
// contracts: Belt.Map.String.t<InternalExpressionValue.t>, // contracts: Belt.Map.String.t<Reducer_Value.t>,
// aValue: InternalExpressionValue.t, // aValue: Reducer_Value.t,
// ) => { // ) => {
// isITypeOf(modifiedType, aValue)->Belt.Result.flatMap(_result => { // isITypeOf(modifiedType, aValue)->Belt.Result.flatMap(_result => {
// if TypeContracts.checkModifiers(contracts, aValue) { // if TypeContracts.checkModifiers(contracts, aValue) {
@ -113,7 +112,7 @@
// switch anIType { // switch anIType {
// | ItTypeIdentifier(name) => caseTypeIdentifier(name, aValue) // | ItTypeIdentifier(name) => caseTypeIdentifier(name, aValue)
// | ItModifiedType({modifiedType, contracts}) => // | ItModifiedType({modifiedType, contracts}) =>
// caseModifiedType(anIType, modifiedType, contracts, aValue) //{modifiedType: iType, contracts: Belt.Map.String.t<InternalExpressionValue.t>} // caseModifiedType(anIType, modifiedType, contracts, aValue) //{modifiedType: iType, contracts: Belt.Map.String.t<Reducer_Value.t>}
// | ItTypeOr({typeOr}) => caseOr(anIType, typeOr, aValue) // | ItTypeOr({typeOr}) => caseOr(anIType, typeOr, aValue)
// | ItTypeFunction(_) => // | ItTypeFunction(_) =>
// raise( // raise(
@ -129,23 +128,23 @@
// let isTypeOf = ( // let isTypeOf = (
// typeExpressionSourceCode: string, // typeExpressionSourceCode: string,
// aValue: InternalExpressionValue.t, // aValue: Reducer_Value.t,
// reducerFn: Reducer_T.reducerFn, // reducerFn: Reducer_T.reducerFn,
// ): result<InternalExpressionValue.t, ErrorValue.t> => { // ): result<Reducer_Value.t, ErrorValue.t> => {
// switch typeExpressionSourceCode->Reducer_Type_Compile.fromTypeExpression(reducerFn) { // switch typeExpressionSourceCode->Reducer_Type_Compile.fromTypeExpression(reducerFn) {
// | Ok(anIType) => // | Ok(anIType) =>
// switch isITypeOf(anIType, aValue) { // switch isITypeOf(anIType, aValue) {
// | Ok(_) => Ok(aValue) // | Ok(_) => Ok(aValue)
// | Error(T.TypeMismatch(anIType, evValue)) => // | Error(T.TypeMismatch(anIType, evValue)) =>
// Error( // Error(
// ErrorValue.REExpectedType(anIType->T.toString, evValue->InternalExpressionValue.toString), // ErrorValue.REExpectedType(anIType->T.toString, evValue->Reducer_Value.toString),
// ) // )
// } // }
// | Error(error) => Error(error) // Directly propagating - err => err - causes type mismatch // | Error(error) => Error(error) // Directly propagating - err => err - causes type mismatch
// } // }
// } // }
// let checkITypeArguments = (anIType: T.iType, args: array<InternalExpressionValue.t>): result< // let checkITypeArguments = (anIType: T.iType, args: array<Reducer_Value.t>): result<
// bool, // bool,
// T.typeErrorValue, // T.typeErrorValue,
// > => { // > => {
@ -155,7 +154,7 @@
// } // }
// } // }
// let checkITypeArgumentsBool = (anIType: T.iType, args: array<InternalExpressionValue.t>): bool => { // let checkITypeArgumentsBool = (anIType: T.iType, args: array<Reducer_Value.t>): bool => {
// switch checkITypeArguments(anIType, args) { // switch checkITypeArguments(anIType, args) {
// | Ok(_) => true // | Ok(_) => true
// | _ => false // | _ => false
@ -164,16 +163,16 @@
// let checkArguments = ( // let checkArguments = (
// typeExpressionSourceCode: string, // typeExpressionSourceCode: string,
// args: array<InternalExpressionValue.t>, // args: array<Reducer_Value.t>,
// reducerFn: ReducerT.reducerFn, // reducerFn: ReducerT.reducerFn,
// ): result<InternalExpressionValue.t, ErrorValue.t> => { // ): result<Reducer_Value.t, ErrorValue.t> => {
// switch typeExpressionSourceCode->Reducer_Type_Compile.fromTypeExpression(reducerFn) { // switch typeExpressionSourceCode->Reducer_Type_Compile.fromTypeExpression(reducerFn) {
// | Ok(anIType) => // | Ok(anIType) =>
// switch checkITypeArguments(anIType, args) { // switch checkITypeArguments(anIType, args) {
// | Ok(_) => Ok(args->IEvArray) // | Ok(_) => Ok(args->IEvArray)
// | Error(T.TypeMismatch(anIType, evValue)) => // | Error(T.TypeMismatch(anIType, evValue)) =>
// Error( // Error(
// ErrorValue.REExpectedType(anIType->T.toString, evValue->InternalExpressionValue.toString), // ErrorValue.REExpectedType(anIType->T.toString, evValue->Reducer_Value.toString),
// ) // )
// } // }
// | Error(error) => Error(error) // Directly propagating - err => err - causes type mismatch // | Error(error) => Error(error) // Directly propagating - err => err - causes type mismatch

View File

@ -5,12 +5,8 @@ module ErrorValue = Reducer_ErrorValue
type environment = GenericDist.env type environment = GenericDist.env
module T = Reducer_T module T = Reducer_T
let defaultEnvironment: environment = DistributionOperation.defaultEnv
type t = Reducer_T.value type t = Reducer_T.value
type internalExpressionValue = t
type functionCall = (string, array<t>) type functionCall = (string, array<t>)
let rec toString = (aValue: T.value) => let rec toString = (aValue: T.value) =>

View File

@ -1,2 +0,0 @@
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module StdLib = ReducerInterface_StdLib

View File

@ -2,7 +2,6 @@
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
module ErrorValue = Reducer_ErrorValue module ErrorValue = Reducer_ErrorValue
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module ProjectItem = ReducerProject_ProjectItem module ProjectItem = ReducerProject_ProjectItem
module T = ReducerProject_T module T = ReducerProject_T
module Topology = ReducerProject_Topology module Topology = ReducerProject_Topology
@ -19,8 +18,8 @@ let getRunOrderFor = Topology.getRunOrderFor
let createProject = () => { let createProject = () => {
let project: t = { let project: t = {
items: Belt.MutableMap.String.make(), items: Belt.MutableMap.String.make(),
stdLib: ReducerInterface_StdLib.internalStdLib, stdLib: SquiggleLibrary_StdLib.stdLib,
environment: InternalExpressionValue.defaultEnvironment, environment: Reducer_Context.defaultEnvironment,
previousRunOrder: [], previousRunOrder: [],
} }
project project
@ -143,8 +142,8 @@ let setStdLib = (project: t, value: Reducer_T.namespace): unit => {
project.stdLib = value project.stdLib = value
} }
let getEnvironment = (project: t): InternalExpressionValue.environment => project.environment let getEnvironment = (project: t): Reducer_T.environment => project.environment
let setEnvironment = (project: t, value: InternalExpressionValue.environment): unit => { let setEnvironment = (project: t, value: Reducer_T.environment): unit => {
project.environment = value project.environment = value
} }

View File

@ -1,31 +0,0 @@
// module ProjectItemT = ReducerProject_ProjectItem_T
// module InternalExpressionValue = ReducerInterface_InternalExpressionValue
// type states = {mutable continuation: ProjectItemT.continuationArgumentType}
// type projectAccessors = {
// stdLib: Reducer_Bindings.t,
// environment: Reducer_T.environment,
// states: states,
// }
// type t = projectAccessors
// let identityAccessors: t = {
// // We need the states at the end of the runtime.
// // Accessors can be modified but states will stay as the same pointer
// states: {
// continuation: Reducer_Bindings.emptyBindings,
// },
// stdLib: ReducerInterface_StdLib.internalStdLib,
// environment: InternalExpressionValue.defaultEnvironment,
// }
// // to support change of environment in runtime
// let setEnvironment = (this: t, environment: Reducer_T.environment): t => {
// {
// ...this,
// environment: environment,
// }
// }

View File

@ -1,6 +1,6 @@
exception ErrorException = Reducer_ErrorValue.ErrorException exception ErrorException = Reducer_ErrorValue.ErrorException
let internalStdLib: Reducer_T.namespace = { let stdLib: Reducer_T.namespace = {
// constants // constants
let res = let res =
Reducer_Namespace.make() Reducer_Namespace.make()

View File

@ -1,58 +0,0 @@
open ForTS__Types
/*
This is meant as a file to contain @genType declarations as needed for Typescript.
I would ultimately want to have all @genType declarations here, vs. other files, but
@genType doesn't play as nicely with renaming Modules and functions as
would be preferable.
The below few seem to work fine. In the future there's definitely more work to do here.
*/
// For backwards compatibility:
//Alternatives if one wants to keep the old habits
@genType type samplingParams = environment
@genType type squiggleValue_Dist = squiggleValue_Distribution //alternative
@genType type genericDist = squiggleValue_Distribution //alternative
@genType type sampleSetDist = sampleSetDistribution //alternative
@genType type symbolicDist = symbolicDistribution //alternative
@genType type resultDist = result<distribution, distributionError> //alternative
@genType type resultFloat = result<float, distributionError> //alternative
@genType type resultString = result<string, distributionError> //alternative
@genType
let makeSampleSetDist: array<float> => result<
sampleSetDist,
SampleSetDist.sampleSetError,
> = SampleSetDist.make
//TODO: ForTS Interface module candid
@genType
let toPointSet: (
squiggleValue_Distribution,
~xyPointLength: int,
~sampleCount: int,
~xSelection: DistributionTypes.DistributionOperation.pointsetXSelection=?,
unit,
) => result<PointSetTypes.pointSetDist, distributionError> = GenericDist.toPointSet
@genType
type mixedShape = PointSetTypes.mixedShape
@genType
type discreteShape = PointSetTypes.discreteShape
@genType
type continuousShape = PointSetTypes.continuousShape
@genType
let distributionErrorToString = ForTS_Distribution_Error.toString
@genType
let defaultSamplingEnv = ForTS_Distribution.defaultEnvironment
// Umur: opaque types
// @genType
// type declarationArg = Declaration.arg
// @genType
// type declaration<'a> = Declaration.declaration<'a>