make ts compatible

commit 94803421acd2e5cb3a0f88e10f9244d374fab20b
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 08:48:33 2022 +0200

    note on old habbits

commit 2c47f80fce8fa6c12cb53b97f7150758eaa74b88
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 08:18:16 2022 +0200

    getTag returns enum value

commit 733b9a820f1d01b618708896451a112d638ee811
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 07:07:30 2022 +0200

    result

commit 64698f4a930182b3ccf122849824e4b6df251a9f
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 06:48:30 2022 +0200

    return tags as ts enum

commit 8ac802428a7aaac5367f5e8a9aaa592b89e305eb
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 06:16:26 2022 +0200

    export tags

commit 6c843e475a98ca1fcfa893d09d45ac9ad7c633ee
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 06:11:00 2022 +0200

    distribution tag

commit 9a43ec30fcaf967a672475431243949748d00bc7
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 05:46:24 2022 +0200

    opaque result

commit f89bdd47c41135135baac99b18faf1c418cc4142
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 05:24:18 2022 +0200

    make ts compilable

    commit 6609bb3691b08405639e6f20da0fad309f2f232e
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 05:21:34 2022 +0200

        compiles

    commit bace3eca63079de8f285069c65b219601e7310bf
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 04:33:34 2022 +0200

        rescript compiles

    commit cd095f605c543902edec08fdcd407600296ec0cb
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 02:40:31 2022 +0200

        squiggleValue

    commit 9b78b5d6c8b69287458fe392f142ceb3bca99407
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 02:37:11 2022 +0200

        project

    commit 20c8693b1eb6492f1662bedbb26b469aac11f8ff
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 00:59:44 2022 +0200

        compiles
This commit is contained in:
Umur Ozkul 2022-08-22 08:50:59 +02:00
parent 25fb6dec82
commit e6464dbe5c
38 changed files with 546 additions and 287 deletions

View File

@ -10,7 +10,6 @@ Instead of a global function namespace we should use modules under ForTS directl
*/ */
import * as _ from "lodash"; import * as _ from "lodash";
import type { import type {
environment, environment,
@ -57,7 +56,6 @@ export let defaultSamplingInputs: environment = {
xyPointLength: 10000, xyPointLength: 10000,
}; };
/* Umur: All the functions below are invalid. ForTS_Reducer project is the new way to do this. */ /* Umur: All the functions below are invalid. ForTS_Reducer project is the new way to do this. */
// export function run( // export function run(

View File

@ -1,19 +1,23 @@
import * as _ from "lodash"; /**
import type { Umur: Delete this file! There is nothing left to see here.
expressionValue, **/
mixedShape,
sampleSetDist, // import * as _ from "lodash";
genericDist, // import type {
environment, // // expressionValue,
symbolicDist, // mixedShape,
discreteShape, // sampleSetDist,
continuousShape, // genericDist,
lambdaValue, // // environment,
lambdaDeclaration, // symbolicDist,
declarationArg, // discreteShape,
} from "../rescript/TypescriptInterface.gen"; // continuousShape,
import { Distribution } from "./distribution"; // // lambdaValue,
import { tagged, tag } from "./types"; // // lambdaDeclaration,
// // declarationArg,
// } from "../rescript/TypescriptInterface.gen";
// import { Distribution } from "./distribution";
// import { tagged, tag } from "./types";
// This file is here to compensate for genType not fully recursively converting types // This file is here to compensate for genType not fully recursively converting types
// Raw rescript types. // Raw rescript types.
@ -81,24 +85,26 @@ import { tagged, tag } from "./types";
// _0: { [key: string]: rescriptExport }; // _0: { [key: string]: rescriptExport };
// }; // };
type rescriptDist = // Umur: opaque type
| { TAG: 0; _0: rescriptPointSetDist } // type rescriptDist =
| { TAG: 1; _0: sampleSetDist } // | { TAG: 0; _0: rescriptPointSetDist }
| { TAG: 2; _0: symbolicDist }; // | { TAG: 1; _0: sampleSetDist }
// | { TAG: 2; _0: symbolicDist };
type rescriptPointSetDist = // Umur: opaque type, no conversion
| { // type rescriptPointSetDist =
TAG: 0; // Mixed // | {
_0: mixedShape; // TAG: 0; // Mixed
} // _0: mixedShape;
| { // }
TAG: 1; // Discrete // | {
_0: discreteShape; // TAG: 1; // Discrete
} // _0: discreteShape;
| { // }
TAG: 2; // ContinuousShape // | {
_0: continuousShape; // TAG: 2; // ContinuousShape
}; // _0: continuousShape;
// };
// type rescriptLambdaDeclaration = { // type rescriptLambdaDeclaration = {
// readonly fn: lambdaValue; // readonly fn: lambdaValue;
@ -211,32 +217,33 @@ type rescriptPointSetDist =
// } // }
// } // }
function convertRawDistributionToGenericDist( // Umur: opaque type no conversion!
result: rescriptDist // function convertRawDistributionToGenericDist(
): genericDist { // result: rescriptDist
switch (result.TAG) { // ): genericDist {
case 0: // Point Set Dist // switch (result.TAG) {
switch (result._0.TAG) { // case 0: // Point Set Dist
case 0: // Mixed // switch (result._0.TAG) {
return tag("PointSet", tag("Mixed", result._0._0)); // case 0: // Mixed
case 1: // Discrete // return tag("PointSet", tag("Mixed", result._0._0));
return tag("PointSet", tag("Discrete", result._0._0)); // case 1: // Discrete
case 2: // Continuous // return tag("PointSet", tag("Discrete", result._0._0));
return tag("PointSet", tag("Continuous", result._0._0)); // case 2: // Continuous
} // return tag("PointSet", tag("Continuous", result._0._0));
case 1: // Sample Set Dist // }
return tag("SampleSet", result._0); // case 1: // Sample Set Dist
case 2: // Symbolic Dist // return tag("SampleSet", result._0);
return tag("Symbolic", result._0); // case 2: // Symbolic Dist
} // return tag("Symbolic", result._0);
} // }
// }
export type jsValue = // export type jsValue =
| string // | string
| number // | number
| jsValue[] // | jsValue[]
| { [key: string]: jsValue } // | { [key: string]: jsValue }
| boolean; // | boolean;
// export function jsValueToBinding(value: jsValue): rescriptExport { // export function jsValueToBinding(value: jsValue): rescriptExport {
// if (typeof value === "boolean") { // if (typeof value === "boolean") {

View File

@ -1,3 +1,4 @@
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
type functionCallInfo = DistributionTypes.DistributionOperation.genericFunctionCallInfo type functionCallInfo = DistributionTypes.DistributionOperation.genericFunctionCallInfo
type genericDist = DistributionTypes.genericDist type genericDist = DistributionTypes.genericDist
type error = DistributionTypes.error type error = DistributionTypes.error

View File

@ -1,3 +1,4 @@
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
@genType @genType
let defaultEnv: GenericDist.env let defaultEnv: GenericDist.env

View File

@ -1,4 +1,5 @@
@genType //FIXME accessor methods or not opaque?
@genType.opaque
type genericDist = type genericDist =
| PointSet(PointSetTypes.pointSetDist) | PointSet(PointSetTypes.pointSetDist)
| SampleSet(SampleSetDist.t) | SampleSet(SampleSetDist.t)
@ -6,6 +7,7 @@ type genericDist =
type asAlgebraicCombinationStrategy = AsDefault | AsSymbolic | AsMonteCarlo | AsConvolution type asAlgebraicCombinationStrategy = AsDefault | AsSymbolic | AsMonteCarlo | AsConvolution
@genType.opaque
type error = type error =
| NotYetImplemented | NotYetImplemented
| Unreachable | Unreachable

View File

@ -1,4 +1,6 @@
//TODO: multimodal, add interface, test somehow, track performance, refactor sampleSet, refactor ASTEvaluator.res. //TODO: multimodal, add interface, test somehow, track performance, refactor sampleSet, refactor ASTEvaluator.res.
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
type t = DistributionTypes.genericDist type t = DistributionTypes.genericDist
type error = DistributionTypes.error type error = DistributionTypes.error
type toPointSetFn = t => result<PointSetTypes.pointSetDist, error> type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>

View File

@ -1,3 +1,5 @@
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
type t = DistributionTypes.genericDist type t = DistributionTypes.genericDist
type error = DistributionTypes.error type error = DistributionTypes.error
type toPointSetFn = t => result<PointSetTypes.pointSetDist, error> type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>

View File

@ -47,7 +47,7 @@ type pointSetDistMonad<'a, 'b, 'c> =
| Discrete('b) | Discrete('b)
| Continuous('c) | Continuous('c)
@genType @genType.opaque
type pointSetDist = pointSetDistMonad<mixedShape, discreteShape, continuousShape> type pointSetDist = pointSetDistMonad<mixedShape, discreteShape, continuousShape>
module ShapeMonad = { module ShapeMonad = {

View File

@ -0,0 +1,57 @@
// Genetic Distribution happens to be abstract distribution
@genType type distribution = DistributionTypes.genericDist
@genType type pointSetDistribution = ForTS_Distribution_PointSetDistribution.pointSetDistribution
@genType type sampleSetDistribution = ForTS_Distribution_SampleSetDistribution.sampleSetDistribution
@genType type symbolicDistribution = ForTS_Distribution_SymbolicDistribution.symbolicDistribution
type environment = ForTS_Distribution_Environment.environment //use
@genType
let defaultEnvironment: environment = DistributionOperation.defaultEnv
@module("ForTS_Distribution_tag") @scope("distributionTag")
external dtPointSet_: int = "DtPointSet"
@module("ForTS_Distribution_tag") @scope("distributionTag")
external dtSampleSet_: int = "DtSampleSet"
@module("ForTS_Distribution_tag") @scope("distributionTag")
external dtSymbolic_: int = "DtSymbolic"
@genType.import("./ForTS_Distribution_tag")
type distributionTag
external castEnum: int => distributionTag = "%identity"
// type genericDist =
// | PointSet(PointSetTypes.pointSetDist)
// | SampleSet(SampleSetDist.t)
// | Symbolic(SymbolicDistTypes.symbolicDist)
@genType
let getTag = (variant: distribution): distributionTag =>
switch variant {
| PointSet(_) => dtPointSet_->castEnum
| SampleSet(_) => dtSampleSet_->castEnum
| Symbolic(_) => dtSymbolic_->castEnum
}
@genType
let getPointSet = (variant: distribution): option<pointSetDistribution> =>
switch variant {
| PointSet(dist) => dist->Some
| _ => None
}
@genType
let getSampleSet = (variant: distribution): option<sampleSetDistribution> =>
switch variant {
| SampleSet(dist) => dist->Some
| _ => None
}
@genType
let getSymbolic = (variant: distribution): option<symbolicDistribution> =>
switch variant {
| Symbolic(dist) => dist->Some
| _ => None
}

View File

@ -0,0 +1 @@
@genType type environment = GenericDist.env //re-export

View File

@ -1,4 +1,4 @@
open ForTS__Types @genType type distributionError = DistributionTypes.error
@genType @genType
let toString = (e: distributionError) => DistributionTypes.Error.toString(e) let toString = (e: distributionError) => DistributionTypes.Error.toString(e)

View File

@ -0,0 +1,44 @@
@genType type pointSetDistribution = PointSetTypes.pointSetDist
@module("ForTS_Distribution_PointSetDistribution_tag") @scope("pointSetDistributionTag")
external pstMixed_: int = "PstMixed"
@module("ForTS_Distribution_PointSetDistribution_tag") @scope("pointSetDistributionTag")
external pstDiscrete_: int = "PstDiscrete"
@module("ForTS_Distribution_PointSetDistribution_tag") @scope("pointSetDistributionTag")
external pstContinuous_: int = "PstContinuous"
@genType.import("./ForTS_Distribution_PointSetDistribution_tag")
type pointSetDistributionTag
external castEnum: int => pointSetDistributionTag = "%identity"
@genType
let getTag = (variant: pointSetDistribution): pointSetDistributionTag =>
switch variant {
| Mixed(_) => pstMixed_->castEnum
| Discrete(_) => pstDiscrete_->castEnum
| Continuous(_) => pstContinuous_->castEnum
}
@genType
let getMixed = (variant: pointSetDistribution): 'd =>
switch variant {
| Mixed(mixed) => mixed->Some
| _ => None
}
@genType
let getDiscrete = (variant: pointSetDistribution): 'd =>
switch variant {
| Discrete(discrete) => discrete->Some
| _ => None
}
@genType
let getContinues = (variant: pointSetDistribution): 'd =>
switch variant {
| Continuous(continuous) => continuous->Some
| _ => None
}

View File

@ -0,0 +1,15 @@
"use strict";
exports.__esModule = true;
exports.pointSetDistributionTag = void 0;
var pointSetDistributionTag;
(function (pointSetDistributionTag) {
pointSetDistributionTag[(pointSetDistributionTag["PstMixed"] = 0)] =
"PstMixed";
pointSetDistributionTag[(pointSetDistributionTag["PstDiscrete"] = 1)] =
"PstDiscrete";
pointSetDistributionTag[(pointSetDistributionTag["PstContinuous"] = 2)] =
"PstContinuous";
})(
(pointSetDistributionTag =
exports.pointSetDistributionTag || (exports.pointSetDistributionTag = {}))
);

View File

@ -0,0 +1,5 @@
export enum pointSetDistributionTag {
PstMixed,
PstDiscrete,
PstContinuous,
}

View File

@ -0,0 +1 @@
@genType type sampleSetDistribution = SampleSetDist.t

View File

@ -0,0 +1 @@
@genType type symbolicDistribution = SymbolicDistTypes.symbolicDist

View File

@ -0,0 +1,5 @@
export enum distributionTag {
DtPointSet,
DtSampleSet,
DtSymbolic,
}

View File

@ -1,6 +1,13 @@
open ForTS__Types @genType type reducerProject = ReducerProject_T.t //re-export
// If a module is built for TypeScript then it can only refer to ForTS__Types for other types and modules
// The exception is its implementation and private modules type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
type reducerErrorValue = ForTS_Reducer_ErrorValue.reducerErrorValue //use
type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
type squiggleValue_Module = ForTS_SquiggleValue_Module.squiggleValue_Module //use
type environment = ForTS_Distribution_Environment.environment //use
module T = ReducerProject_T module T = ReducerProject_T
module Private = ReducerProject.Private module Private = ReducerProject.Private
@ -9,6 +16,8 @@ module Private = ReducerProject.Private
*/ */
/* /*
A project links and runs sources that continue or include each other.
Creates a new project to hold the sources, executables, bindings, and other data. Creates a new project to hold the sources, executables, bindings, and other data.
The new project runs the sources according to their topological sorting because of the includes and continues. The new project runs the sources according to their topological sorting because of the includes and continues.
@ -92,7 +101,7 @@ let cleanAllResults = (project: reducerProject): unit =>
To set the includes one first has to call "parseIncludes". The parsed includes or the parser error is returned. To set the includes one first has to call "parseIncludes". The parsed includes or the parser error is returned.
*/ */
@genType @genType
let getIncludes = (project: reducerProject, sourceId: string): result_< let getIncludes = (project: reducerProject, sourceId: string): result<
array<string>, array<string>,
reducerErrorValue, reducerErrorValue,
> => project->T.Private.castToInternalProject->Private.getIncludes(sourceId) > => project->T.Private.castToInternalProject->Private.getIncludes(sourceId)
@ -145,7 +154,7 @@ let getRunOrderFor = (project: reducerProject, sourceId: string) =>
Parse includes so that you can load them before running. Parse includes so that you can load them before running.
Load includes by calling getIncludes which returns the includes that have been parsed. Load includes by calling getIncludes which returns the includes that have been parsed.
It is your responsibility to load the includes before running. It is your responsibility to load the includes before running.
*/ module Topology = ReducerProject_Topology */
@genType @genType
let parseIncludes = (project: reducerProject, sourceId: string): unit => let parseIncludes = (project: reducerProject, sourceId: string): unit =>
@ -186,7 +195,7 @@ Get the result after running this source file or the project
*/ */
@genType @genType
let getResult = (project: reducerProject, sourceId: string): option< let getResult = (project: reducerProject, sourceId: string): option<
result_<squiggleValue, reducerErrorValue>, result<squiggleValue, reducerErrorValue>,
> => project->T.Private.castToInternalProject->Private.getResult(sourceId) > => project->T.Private.castToInternalProject->Private.getResult(sourceId)
/* /*
@ -194,7 +203,11 @@ This is a convenience function to get the result of a single source without crea
However, without a project, you cannot handle include directives. However, without a project, you cannot handle include directives.
The source has to be include free The source has to be include free
*/ */
@genType let evaluate = (sourceCode: string): ('r, 'b) => Private.evaluate(sourceCode) @genType
let evaluate = (sourceCode: string): (
result<squiggleValue, reducerErrorValue>,
squiggleValue_Module,
) => Private.evaluate(sourceCode)
@genType @genType
let setEnvironment = (project: reducerProject, environment: environment): unit => let setEnvironment = (project: reducerProject, environment: environment): unit =>
@ -211,7 +224,7 @@ If the conversion to the new project is too difficult, I can add it later.
// lambdaValue: squiggleValue_Lambda, // lambdaValue: squiggleValue_Lambda,
// argArray: array<squiggleValue>, // argArray: array<squiggleValue>,
// environment: environment, // environment: environment,
// ): result_<squiggleValue, reducerErrorValue> => { // ): result<squiggleValue, reducerErrorValue> => {
// let accessors = ReducerProject_ProjectAccessors_T.identityAccessorsWithEnvironment(environment) // let accessors = ReducerProject_ProjectAccessors_T.identityAccessorsWithEnvironment(environment)
// Reducer_Expression_Lambda.foreignFunctionInterface( // Reducer_Expression_Lambda.foreignFunctionInterface(
// lambdaValue, // lambdaValue,

View File

@ -1,4 +1,5 @@
open ForTS__Types @genType type reducerErrorValue = Reducer_ErrorValue.errorValue //alias
@genType type syntaxErrorLocation = Reducer_ErrorValue.syntaxErrorLocation //alias
@genType @genType
let toString = (e: reducerErrorValue): string => Reducer_ErrorValue.errorToString(e) let toString = (e: reducerErrorValue): string => Reducer_ErrorValue.errorToString(e)

View File

@ -1,4 +1,5 @@
open ForTS__Types @genType.opaque type result_<'a, 'e> = result<'a, 'e>
@genType type result<'a, 'e> = result_<'a, 'e> // alias and re-export
@genType let isError = (r: result_<'a, 'e>): bool => Belt.Result.isError(r) @genType let isError = (r: result_<'a, 'e>): bool => Belt.Result.isError(r)
@genType let isOk = (r: result_<'a, 'e>): bool => Belt.Result.isOk(r) @genType let isOk = (r: result_<'a, 'e>): bool => Belt.Result.isOk(r)
@ -11,27 +12,32 @@ let getError = (r: result_<'a, 'e>): option<'e> =>
} }
@genType @genType
let getValue = (r: result_<'a, 'e>): option<'a> => let getValue = (r: result<'a, 'e>): option<'a> =>
switch r { switch r {
| Ok(v) => Some(v) | Ok(v) => Some(v)
| Error(_) => None | Error(_) => None
} }
@module("ForTS_Result_tag") @scope("ResultTag") @module("ForTS_Result_tag") @scope("resultTag")
external rtOk_: int = "RtOk" external rtOk_: int = "RtOk"
@module("ForTS_Result_tag") @scope("ResultTag") @module("ForTS_Result_tag") @scope("resultTag")
external rtError_: int = "RtError" external rtError_: int = "RtError"
@genType.import("./ForTS_Result_tag")
type resultTag
external castEnum: int => resultTag = "%identity"
@genType @genType
let getTag = (r: result_<'a, 'e>): int => let getTag = (r: result<'a, 'e>): resultTag =>
switch r { switch r {
| Ok(_) => rtOk_ | Ok(_) => rtOk_->castEnum
| Error(_) => rtError_ | Error(_) => rtError_->castEnum
} }
@genType @genType
let fmap = (r: result_<'a, 'e>, f: 'a => 'b): result_<'b, 'e> => let fmap = (r: result<'a, 'e>, f: 'a => 'b): result<'b, 'e> =>
switch r { switch r {
| Ok(v) => Ok(f(v)) | Ok(v) => Ok(f(v))
| Error(e) => Error(e) | Error(e) => Error(e)

View File

@ -1,4 +1,4 @@
enum ResultTag { export enum resultTag {
Ok, Ok,
Error, Error,
} }

View File

@ -1,78 +1,93 @@
open ForTS__Types @genType type squiggleValue = ReducerInterface_InternalExpressionValue.t //re-export
type result_<'a, 'e> = ForTS_Result.result_<'a, 'e> //use
type reducerErrorValue = ForTS_Reducer_ErrorValue.reducerErrorValue //use
// Return values as they are if they are JavaScript types. @genType type squiggleValue_Array = ReducerInterface_InternalExpressionValue.squiggleArray //re-export recursive type
@genType type squiggleValue_Module = ReducerInterface_InternalExpressionValue.nameSpace //re-export recursive type
@genType type squiggleValue_Record = ReducerInterface_InternalExpressionValue.map //re-export recursive type
@genType type squiggleValue_Type = ReducerInterface_InternalExpressionValue.map //re-export recursive type
type squiggleValue_Declaration = ForTS_SquiggleValue_Declaration.squiggleValue_Declaration //use
type squiggleValue_Distribution = ForTS_SquiggleValue_Distribution.squiggleValue_Distribution //use
type squiggleValue_Lambda = ForTS_SquiggleValue_Lambda.squiggleValue_Lambda //use
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") // Return values are kept as they are if they are JavaScript types.
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtArray_: int = "SvtArray" external svtArray_: int = "SvtArray"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtArrayString_: int = "SvtArrayString" external svtArrayString_: int = "SvtArrayString"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtBool_: int = "SvtBool" external svtBool_: int = "SvtBool"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtCall_: int = "SvtCall" external svtCall_: int = "SvtCall"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtDate_: int = "SvtDate" external svtDate_: int = "SvtDate"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtDeclaration_: int = "SvtDeclaration" external svtDeclaration_: int = "SvtDeclaration"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtDistribution_: int = "SvtDistribution" external svtDistribution_: int = "SvtDistribution"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtLambda_: int = "SvtLambda" external svtLambda_: int = "SvtLambda"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtModule_: int = "SvtModule" external svtModule_: int = "SvtModule"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtNumber_: int = "SvtNumber" external svtNumber_: int = "SvtNumber"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtRecord_: int = "SvtRecord" external svtRecord_: int = "SvtRecord"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtString_: int = "SvtString" external svtString_: int = "SvtString"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtSymbol_: int = "SvtSymbol" external svtSymbol_: int = "SvtSymbol"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtTimeDuration_: int = "SvtTimeDuration" external svtTimeDuration_: int = "SvtTimeDuration"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtType_: int = "SvtType" external svtType_: int = "SvtType"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtTypeIdentifier_: int = "SvtUndefined" external svtTypeIdentifier_: int = "SvtUndefined"
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag") @module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
external svtVoid_: int = "SvtVoid" external svtVoid_: int = "SvtVoid"
@genType.import("./ForTS_SquiggleValue_tag")
type squiggleValueTag
external castEnum: int => squiggleValueTag = "%identity"
@genType @genType
let getTag = (variant: squiggleValue) => let getTag = (variant: squiggleValue): squiggleValueTag =>
switch variant { switch variant {
| IEvArray(_) => svtArray_ | IEvArray(_) => svtArray_->castEnum
| IEvArrayString(_) => svtArrayString_ | IEvArrayString(_) => svtArrayString_->castEnum
| IEvBool(_) => svtBool_ | IEvBool(_) => svtBool_->castEnum
| IEvCall(_) => svtCall_ //Impossible | IEvCall(_) => svtCall_->castEnum //Impossible
| IEvDate(_) => svtDate_ | IEvDate(_) => svtDate_->castEnum
| IEvDeclaration(_) => svtDeclaration_ | IEvDeclaration(_) => svtDeclaration_->castEnum
| IEvDistribution(_) => svtDistribution_ | IEvDistribution(_) => svtDistribution_->castEnum
| IEvLambda(_) => svtLambda_ | IEvLambda(_) => svtLambda_->castEnum
| IEvBindings(_) => svtModule_ //Impossible | IEvBindings(_) => svtModule_->castEnum //Impossible
| IEvNumber(_) => svtNumber_ | IEvNumber(_) => svtNumber_->castEnum
| IEvRecord(_) => svtRecord_ | IEvRecord(_) => svtRecord_->castEnum
| IEvString(_) => svtString_ | IEvString(_) => svtString_->castEnum
| IEvSymbol(_) => svtSymbol_ | IEvSymbol(_) => svtSymbol_->castEnum
| IEvTimeDuration(_) => svtTimeDuration_ | IEvTimeDuration(_) => svtTimeDuration_->castEnum
| IEvType(_) => svtType_ | IEvType(_) => svtType_->castEnum
| IEvTypeIdentifier(_) => svtTypeIdentifier_ | IEvTypeIdentifier(_) => svtTypeIdentifier_->castEnum
| IEvVoid => svtVoid_ | IEvVoid => svtVoid_->castEnum
} }
@genType @genType

View File

@ -1,6 +1,5 @@
open ForTS__Types type squiggleValue = ForTS_SquiggleValue.squiggleValue
// Note: Internal representation will not be an array in the future. @genType type squiggleValue_Array = ForTS_SquiggleValue.squiggleValue_Array //re-export recursive type
// Thus we still to have a conversion
@genType @genType
let getValues = (v: squiggleValue_Array): array<squiggleValue> => let getValues = (v: squiggleValue_Array): array<squiggleValue> =>

View File

@ -0,0 +1 @@
@genType type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambdaDeclaration //re-export

View File

@ -0,0 +1 @@
@genType type squiggleValue_Distribution = ForTS_Distribution.distribution

View File

@ -0,0 +1 @@
@genType type squiggleValue_Lambda = ReducerInterface_InternalExpressionValue.lambdaValue //re-export

View File

@ -1,4 +1,5 @@
open ForTS__Types type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
@genType type squiggleValue_Module = ForTS_SquiggleValue.squiggleValue_Module //re-export recursive type
@genType @genType
let getKeyValuePairs = (v: squiggleValue_Module): array<(string, squiggleValue)> => let getKeyValuePairs = (v: squiggleValue_Module): array<(string, squiggleValue)> =>

View File

@ -1,4 +1,5 @@
open ForTS__Types type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
@genType type squiggleValue_Record = ForTS_SquiggleValue.squiggleValue_Record //re-export recursive type
@genType @genType
let getKeyValuePairs = (value: squiggleValue_Record): array<(string, squiggleValue)> => let getKeyValuePairs = (value: squiggleValue_Record): array<(string, squiggleValue)> =>

View File

@ -1,4 +1,5 @@
open ForTS__Types type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
@genType type squiggleValue_Type = ForTS_SquiggleValue.squiggleValue_Type //re-export recursive type
@genType @genType
let getKeyValuePairs = (value: squiggleValue_Type): array<(string, squiggleValue)> => let getKeyValuePairs = (value: squiggleValue_Type): array<(string, squiggleValue)> =>

View File

@ -0,0 +1,19 @@
export enum squiggleValueTag {
SvtArray,
SvtArrayString,
SvtBool,
SvtCall,
SvtDate,
SvtDeclaration,
SvtDistribution,
SvtLambda,
SvtModule,
SvtNumber,
SvtRecord,
SvtString,
SvtSymbol,
SvtTimeDuration,
SvtType,
SvtTypeIdentifier,
SvtVoid,
}

View File

@ -1,19 +0,0 @@
enum SquiggleValueTag {
SvtArray,
SvtArrayString,
SvtBool,
SvtCall,
SvtDate,
SvtDeclaration,
SvtDistribution,
SvtLambda,
SvtModule,
SvtNumber,
SvtRecord,
SvtString,
SvtSymbol,
SvtTimeDuration,
SvtType,
SvtTypeIdentifier,
SvtVoid,
}

View File

@ -1,31 +1,24 @@
@genType.opaque type result_<'a, 'e> = result<'a, 'e> @genType type result_<'a, 'e> = ForTS_Result.result_<'a, 'e> //re-export
@genType.opaque type reducerErrorValue = Reducer_ErrorValue.errorValue @genType type result<'a, 'e> = ForTS_Result.result<'a, 'e> //re-export
@genType type syntaxErrorLocation = Reducer_ErrorValue.syntaxErrorLocation @genType type reducerErrorValue = ForTS_Reducer_ErrorValue.reducerErrorValue //re-export
@genType type syntaxErrorLocation = ForTS_Reducer_ErrorValue.syntaxErrorLocation //re-export
/* @genType type reducerProject = ForTS_ReducerProject.reducerProject //re-export
The reason this is not ExpressionValue is that ExpressionValue is becoming a parametric type @genType type squiggleValue = ForTS_SquiggleValue.squiggleValue //re-export
to allow expressions for different domains. @genType type squiggleValue_Array = ForTS_SquiggleValue_Array.squiggleValue_Array //re-export
So we rename it right away not cause a compatibility problem @genType type squiggleValue_Declaration = ForTS_SquiggleValue_Declaration.squiggleValue_Declaration //re-export
*/ @genType type squiggleValue_Lambda = ForTS_SquiggleValue_Lambda.squiggleValue_Lambda //re-export
@genType.opaque type squiggleValue = ReducerInterface_InternalExpressionValue.t @genType type squiggleValue_Module = ForTS_SquiggleValue_Module.squiggleValue_Module //re-export
@genType.opaque type squiggleValue_Array = ReducerInterface_InternalExpressionValue.squiggleArray @genType type squiggleValue_Record = ForTS_SquiggleValue_Record.squiggleValue_Record //re-export
@genType.opaque @genType type squiggleValue_Type = ForTS_SquiggleValue_Type.squiggleValue_Type //re-export
type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambdaDeclaration
@genType.opaque type squiggleValue_Module = ReducerInterface_InternalExpressionValue.nameSpace
@genType.opaque type squiggleValue_Lambda = ReducerInterface_InternalExpressionValue.lambdaValue
@genType.opaque type squiggleValue_Record = ReducerInterface_InternalExpressionValue.map
@genType.opaque type squiggleValue_Type = ReducerInterface_InternalExpressionValue.map
@genType.opaque type reducerProject = ReducerProject_T.t
/* Distribution related */ /* Distribution related */
@genType type environment = GenericDist.env @genType type squiggleValue_Distribution = ForTS_Distribution.distribution //re-export
@genType.opaque @genType type distribution = squiggleValue_Distribution //candid
type distributionError = DistributionTypes.error @genType type distributionError = ForTS_Distribution_Error.distributionError //re-export
@genType type environment = ForTS_Distribution_Environment.environment //re-export
// From now on one should introduce any new types as opaque types. @genType type pointSetDistribution = ForTS_Distribution_PointSetDistribution.pointSetDistribution //re-export
// Exception: The intended type is really a JavaScript type or record. Not by coincidence @genType type sampleSetDistribution = ForTS_Distribution_SampleSetDistribution.sampleSetDistribution //re-export
// Already existing open types we cannot dive in now @genType type symbolicDistribution = ForTS_Distribution_SymbolicDistribution.symbolicDistribution //re-export
@genType type squiggleValue_Distribution = DistributionTypes.genericDist
//TODO: index.ts should use types from here or vice versa

View File

@ -1,4 +0,0 @@
open ForTS__Types
@genType
let defaultEnvironment: environment = DistributionOperation.defaultEnv

View File

@ -2,6 +2,7 @@
@gentype.import("peggy") @genType.as("LocationRange") @gentype.import("peggy") @genType.as("LocationRange")
type syntaxErrorLocation type syntaxErrorLocation
@genType.opaque
type errorValue = type errorValue =
| REArityError(option<string>, int, int) | REArityError(option<string>, int, int)
| REArrayIndexNotFound(string, int) | REArrayIndexNotFound(string, int)

View File

@ -5,6 +5,7 @@ type environment = GenericDist.env
let defaultEnvironment: environment = DistributionOperation.defaultEnv let defaultEnvironment: environment = DistributionOperation.defaultEnv
@genType.opaque
type rec t = type rec t =
| IEvArray(array<t>) // FIXME: Convert to MapInt | IEvArray(array<t>) // FIXME: Convert to MapInt
| IEvArrayString(array<string>) | IEvArrayString(array<string>)
@ -23,17 +24,17 @@ type rec t =
| IEvType(map) | IEvType(map)
| IEvTypeIdentifier(string) | IEvTypeIdentifier(string)
| IEvVoid | IEvVoid
and squiggleArray = array<t> @genType.opaque and squiggleArray = array<t>
and map = Belt.Map.String.t<t> @genType.opaque and map = Belt.Map.String.t<t>
and nameSpace = NameSpace(Belt.Map.String.t<t>) @genType.opaque and nameSpace = NameSpace(Belt.Map.String.t<t>)
@genType.opaque
and lambdaValue = { and lambdaValue = {
parameters: array<string>, parameters: array<string>,
context: nameSpace, context: nameSpace,
body: internalCode, body: internalCode,
} }
and lambdaDeclaration = Declaration.declaration<lambdaValue> @genType.opaque and lambdaDeclaration = Declaration.declaration<lambdaValue>
type squiggleMap = map
type internalExpressionValue = t type internalExpressionValue = t
type functionCall = (string, array<t>) type functionCall = (string, array<t>)

View File

@ -5,7 +5,9 @@
"use strict"; "use strict";
function peg$subclass(child, parent) { function peg$subclass(child, parent) {
function C() { this.constructor = child; } function C() {
this.constructor = child;
}
C.prototype = parent.prototype; C.prototype = parent.prototype;
child.prototype = new C(); child.prototype = new C();
} }
@ -27,13 +29,15 @@ peg$subclass(peg$SyntaxError, Error);
function peg$padEnd(str, targetLength, padString) { function peg$padEnd(str, targetLength, padString) {
padString = padString || " "; padString = padString || " ";
if (str.length > targetLength) { return str; } if (str.length > targetLength) {
return str;
}
targetLength -= str.length; targetLength -= str.length;
padString += padString.repeat(targetLength); padString += padString.repeat(targetLength);
return str + padString.slice(0, targetLength); return str + padString.slice(0, targetLength);
} }
peg$SyntaxError.prototype.format = function(sources) { peg$SyntaxError.prototype.format = function (sources) {
var str = "Error: " + this.message; var str = "Error: " + this.message;
if (this.location) { if (this.location) {
var src = null; var src = null;
@ -48,15 +52,24 @@ peg$SyntaxError.prototype.format = function(sources) {
var loc = this.location.source + ":" + s.line + ":" + s.column; var loc = this.location.source + ":" + s.line + ":" + s.column;
if (src) { if (src) {
var e = this.location.end; var e = this.location.end;
var filler = peg$padEnd("", s.line.toString().length, ' '); var filler = peg$padEnd("", s.line.toString().length, " ");
var line = src[s.line - 1]; var line = src[s.line - 1];
var last = s.line === e.line ? e.column : line.length + 1; var last = s.line === e.line ? e.column : line.length + 1;
var hatLen = (last - s.column) || 1; var hatLen = last - s.column || 1;
str += "\n --> " + loc + "\n" str +=
+ filler + " |\n" "\n --> " +
+ s.line + " | " + line + "\n" loc +
+ filler + " | " + peg$padEnd("", s.column - 1, ' ') "\n" +
+ peg$padEnd("", hatLen, "^"); filler +
" |\n" +
s.line +
" | " +
line +
"\n" +
filler +
" | " +
peg$padEnd("", s.column - 1, " ") +
peg$padEnd("", hatLen, "^");
} else { } else {
str += "\n at " + loc; str += "\n at " + loc;
} }
@ -64,33 +77,35 @@ peg$SyntaxError.prototype.format = function(sources) {
return str; return str;
}; };
peg$SyntaxError.buildMessage = function(expected, found) { peg$SyntaxError.buildMessage = function (expected, found) {
var DESCRIBE_EXPECTATION_FNS = { var DESCRIBE_EXPECTATION_FNS = {
literal: function(expectation) { literal: function (expectation) {
return "\"" + literalEscape(expectation.text) + "\""; return '"' + literalEscape(expectation.text) + '"';
}, },
class: function(expectation) { class: function (expectation) {
var escapedParts = expectation.parts.map(function(part) { var escapedParts = expectation.parts.map(function (part) {
return Array.isArray(part) return Array.isArray(part)
? classEscape(part[0]) + "-" + classEscape(part[1]) ? classEscape(part[0]) + "-" + classEscape(part[1])
: classEscape(part); : classEscape(part);
}); });
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; return (
"[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"
);
}, },
any: function() { any: function () {
return "any character"; return "any character";
}, },
end: function() { end: function () {
return "end of input"; return "end of input";
}, },
other: function(expectation) { other: function (expectation) {
return expectation.description; return expectation.description;
} },
}; };
function hex(ch) { function hex(ch) {
@ -100,13 +115,17 @@ peg$SyntaxError.buildMessage = function(expected, found) {
function literalEscape(s) { function literalEscape(s) {
return s return s
.replace(/\\/g, "\\\\") .replace(/\\/g, "\\\\")
.replace(/"/g, "\\\"") .replace(/"/g, '\\"')
.replace(/\0/g, "\\0") .replace(/\0/g, "\\0")
.replace(/\t/g, "\\t") .replace(/\t/g, "\\t")
.replace(/\n/g, "\\n") .replace(/\n/g, "\\n")
.replace(/\r/g, "\\r") .replace(/\r/g, "\\r")
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) .replace(/[\x00-\x0F]/g, function (ch) {
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); return "\\x0" + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return "\\x" + hex(ch);
});
} }
function classEscape(s) { function classEscape(s) {
@ -119,8 +138,12 @@ peg$SyntaxError.buildMessage = function(expected, found) {
.replace(/\t/g, "\\t") .replace(/\t/g, "\\t")
.replace(/\n/g, "\\n") .replace(/\n/g, "\\n")
.replace(/\r/g, "\\r") .replace(/\r/g, "\\r")
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) .replace(/[\x00-\x0F]/g, function (ch) {
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); return "\\x0" + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return "\\x" + hex(ch);
});
} }
function describeExpectation(expectation) { function describeExpectation(expectation) {
@ -151,17 +174,25 @@ peg$SyntaxError.buildMessage = function(expected, found) {
return descriptions[0] + " or " + descriptions[1]; return descriptions[0] + " or " + descriptions[1];
default: default:
return descriptions.slice(0, -1).join(", ") return (
+ ", or " descriptions.slice(0, -1).join(", ") +
+ descriptions[descriptions.length - 1]; ", or " +
descriptions[descriptions.length - 1]
);
} }
} }
function describeFound(found) { function describeFound(found) {
return found ? "\"" + literalEscape(found) + "\"" : "end of input"; return found ? '"' + literalEscape(found) + '"' : "end of input";
} }
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; return (
"Expected " +
describeExpected(expected) +
" but " +
describeFound(found) +
" found."
);
}; };
function peg$parse(input, options) { function peg$parse(input, options) {
@ -175,7 +206,7 @@ function peg$parse(input, options) {
var peg$c0 = "#include"; var peg$c0 = "#include";
var peg$c1 = "'"; var peg$c1 = "'";
var peg$c2 = "\""; var peg$c2 = '"';
var peg$c3 = "//"; var peg$c3 = "//";
var peg$c4 = "/*"; var peg$c4 = "/*";
var peg$c5 = "*/"; var peg$c5 = "*/";
@ -191,8 +222,8 @@ function peg$parse(input, options) {
var peg$e1 = peg$otherExpectation("string"); var peg$e1 = peg$otherExpectation("string");
var peg$e2 = peg$literalExpectation("'", false); var peg$e2 = peg$literalExpectation("'", false);
var peg$e3 = peg$classExpectation(["'"], true, false); var peg$e3 = peg$classExpectation(["'"], true, false);
var peg$e4 = peg$literalExpectation("\"", false); var peg$e4 = peg$literalExpectation('"', false);
var peg$e5 = peg$classExpectation(["\""], true, false); var peg$e5 = peg$classExpectation(['"'], true, false);
var peg$e6 = peg$literalExpectation("//", false); var peg$e6 = peg$literalExpectation("//", false);
var peg$e7 = peg$literalExpectation("/*", false); var peg$e7 = peg$literalExpectation("/*", false);
var peg$e8 = peg$classExpectation(["*"], true, false); var peg$e8 = peg$classExpectation(["*"], true, false);
@ -203,12 +234,24 @@ function peg$parse(input, options) {
var peg$e13 = peg$classExpectation(["\n", "\r"], false, false); var peg$e13 = peg$classExpectation(["\n", "\r"], false, false);
var peg$e14 = peg$classExpectation(["\r", "\n"], true, false); var peg$e14 = peg$classExpectation(["\r", "\n"], true, false);
var peg$f0 = function(head, tail) {return [head, ...tail].filter( e => e != '');}; var peg$f0 = function (head, tail) {
var peg$f1 = function() {return [];}; return [head, ...tail].filter((e) => e != "");
var peg$f2 = function(characters) {return characters.join('');}; };
var peg$f3 = function(characters) {return characters.join('');}; var peg$f1 = function () {
var peg$f4 = function() { return '';}; return [];
var peg$f5 = function() { return '';}; };
var peg$f2 = function (characters) {
return characters.join("");
};
var peg$f3 = function (characters) {
return characters.join("");
};
var peg$f4 = function () {
return "";
};
var peg$f5 = function () {
return "";
};
var peg$currPos = 0; var peg$currPos = 0;
var peg$savedPos = 0; var peg$savedPos = 0;
var peg$posDetailsCache = [{ line: 1, column: 1 }]; var peg$posDetailsCache = [{ line: 1, column: 1 }];
@ -222,7 +265,9 @@ function peg$parse(input, options) {
if ("startRule" in options) { if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) { if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); throw new Error(
"Can't start parsing from rule \"" + options.startRule + '".'
);
} }
peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
@ -240,7 +285,7 @@ function peg$parse(input, options) {
return { return {
source: peg$source, source: peg$source,
start: peg$savedPos, start: peg$savedPos,
end: peg$currPos end: peg$currPos,
}; };
} }
@ -249,7 +294,8 @@ function peg$parse(input, options) {
} }
function expected(description, location) { function expected(description, location) {
location = location !== undefined location =
location !== undefined
? location ? location
: peg$computeLocation(peg$savedPos, peg$currPos); : peg$computeLocation(peg$savedPos, peg$currPos);
@ -261,7 +307,8 @@ function peg$parse(input, options) {
} }
function error(message, location) { function error(message, location) {
location = location !== undefined location =
location !== undefined
? location ? location
: peg$computeLocation(peg$savedPos, peg$currPos); : peg$computeLocation(peg$savedPos, peg$currPos);
@ -273,7 +320,12 @@ function peg$parse(input, options) {
} }
function peg$classExpectation(parts, inverted, ignoreCase) { function peg$classExpectation(parts, inverted, ignoreCase) {
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; return {
type: "class",
parts: parts,
inverted: inverted,
ignoreCase: ignoreCase,
};
} }
function peg$anyExpectation() { function peg$anyExpectation() {
@ -303,7 +355,7 @@ function peg$parse(input, options) {
details = peg$posDetailsCache[p]; details = peg$posDetailsCache[p];
details = { details = {
line: details.line, line: details.line,
column: details.column column: details.column,
}; };
while (p < pos) { while (p < pos) {
@ -332,18 +384,20 @@ function peg$parse(input, options) {
start: { start: {
offset: startPos, offset: startPos,
line: startPosDetails.line, line: startPosDetails.line,
column: startPosDetails.column column: startPosDetails.column,
}, },
end: { end: {
offset: endPos, offset: endPos,
line: endPosDetails.line, line: endPosDetails.line,
column: endPosDetails.column column: endPosDetails.column,
} },
}; };
} }
function peg$fail(expected) { function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos < peg$maxFailPos) {
return;
}
if (peg$currPos > peg$maxFailPos) { if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos; peg$maxFailPos = peg$currPos;
@ -501,7 +555,9 @@ function peg$parse(input, options) {
peg$currPos += 8; peg$currPos += 8;
} else { } else {
s1 = peg$FAILED; s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e0); } if (peg$silentFails === 0) {
peg$fail(peg$e0);
}
} }
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
s2 = []; s2 = [];
@ -559,7 +615,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s2 = peg$FAILED; s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e2); } if (peg$silentFails === 0) {
peg$fail(peg$e2);
}
} }
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
s3 = []; s3 = [];
@ -568,7 +626,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s4 = peg$FAILED; s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e3); } if (peg$silentFails === 0) {
peg$fail(peg$e3);
}
} }
while (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) {
s3.push(s4); s3.push(s4);
@ -577,7 +637,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s4 = peg$FAILED; s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e3); } if (peg$silentFails === 0) {
peg$fail(peg$e3);
}
} }
} }
if (input.charCodeAt(peg$currPos) === 39) { if (input.charCodeAt(peg$currPos) === 39) {
@ -585,7 +647,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s4 = peg$FAILED; s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e2); } if (peg$silentFails === 0) {
peg$fail(peg$e2);
}
} }
if (s4 !== peg$FAILED) { if (s4 !== peg$FAILED) {
s1 = s3; s1 = s3;
@ -610,7 +674,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s2 = peg$FAILED; s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e4); } if (peg$silentFails === 0) {
peg$fail(peg$e4);
}
} }
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
s3 = []; s3 = [];
@ -619,7 +685,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s4 = peg$FAILED; s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e5); } if (peg$silentFails === 0) {
peg$fail(peg$e5);
}
} }
while (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) {
s3.push(s4); s3.push(s4);
@ -628,7 +696,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s4 = peg$FAILED; s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e5); } if (peg$silentFails === 0) {
peg$fail(peg$e5);
}
} }
} }
if (input.charCodeAt(peg$currPos) === 34) { if (input.charCodeAt(peg$currPos) === 34) {
@ -636,7 +706,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s4 = peg$FAILED; s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e4); } if (peg$silentFails === 0) {
peg$fail(peg$e4);
}
} }
if (s4 !== peg$FAILED) { if (s4 !== peg$FAILED) {
s1 = s3; s1 = s3;
@ -657,7 +729,9 @@ function peg$parse(input, options) {
peg$silentFails--; peg$silentFails--;
if (s0 === peg$FAILED) { if (s0 === peg$FAILED) {
s1 = peg$FAILED; s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e1); } if (peg$silentFails === 0) {
peg$fail(peg$e1);
}
} }
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -719,7 +793,9 @@ function peg$parse(input, options) {
peg$currPos += 2; peg$currPos += 2;
} else { } else {
s1 = peg$FAILED; s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e6); } if (peg$silentFails === 0) {
peg$fail(peg$e6);
}
} }
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
s2 = []; s2 = [];
@ -758,7 +834,9 @@ function peg$parse(input, options) {
peg$currPos += 2; peg$currPos += 2;
} else { } else {
s1 = peg$FAILED; s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e7); } if (peg$silentFails === 0) {
peg$fail(peg$e7);
}
} }
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
s2 = []; s2 = [];
@ -767,7 +845,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s3 = peg$FAILED; s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e8); } if (peg$silentFails === 0) {
peg$fail(peg$e8);
}
} }
while (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) {
s2.push(s3); s2.push(s3);
@ -776,7 +856,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s3 = peg$FAILED; s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e8); } if (peg$silentFails === 0) {
peg$fail(peg$e8);
}
} }
} }
if (input.substr(peg$currPos, 2) === peg$c5) { if (input.substr(peg$currPos, 2) === peg$c5) {
@ -784,7 +866,9 @@ function peg$parse(input, options) {
peg$currPos += 2; peg$currPos += 2;
} else { } else {
s3 = peg$FAILED; s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e9); } if (peg$silentFails === 0) {
peg$fail(peg$e9);
}
} }
if (s3 !== peg$FAILED) { if (s3 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
@ -821,12 +905,16 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s0 = peg$FAILED; s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e11); } if (peg$silentFails === 0) {
peg$fail(peg$e11);
}
} }
peg$silentFails--; peg$silentFails--;
if (s0 === peg$FAILED) { if (s0 === peg$FAILED) {
s1 = peg$FAILED; s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e10); } if (peg$silentFails === 0) {
peg$fail(peg$e10);
}
} }
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -852,12 +940,16 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s0 = peg$FAILED; s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e13); } if (peg$silentFails === 0) {
peg$fail(peg$e13);
}
} }
peg$silentFails--; peg$silentFails--;
if (s0 === peg$FAILED) { if (s0 === peg$FAILED) {
s1 = peg$FAILED; s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e12); } if (peg$silentFails === 0) {
peg$fail(peg$e12);
}
} }
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -882,7 +974,9 @@ function peg$parse(input, options) {
peg$currPos++; peg$currPos++;
} else { } else {
s0 = peg$FAILED; s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e14); } if (peg$silentFails === 0) {
peg$fail(peg$e14);
}
} }
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
@ -911,5 +1005,5 @@ function peg$parse(input, options) {
module.exports = { module.exports = {
SyntaxError: peg$SyntaxError, SyntaxError: peg$SyntaxError,
parse: peg$parse parse: peg$parse,
}; };

View File

@ -2,7 +2,10 @@ module ProjectItem = ReducerProject_ProjectItem
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module ProjectAccessorsT = ReducerProject_ProjectAccessors_T module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
@genType.opaque
type project = {"tag": string} type project = {"tag": string}
//re-export
@genType
type t = project type t = project
module Private = { module Private = {

View File

@ -8,28 +8,17 @@ would be preferable.
The below few seem to work fine. In the future there's definitely more work to do here. The below few seem to work fine. In the future there's definitely more work to do here.
*/ */
@genType // For backwards compatibility:
type samplingParams = environment //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
type genericDist = squiggleValue_Distribution
@genType
type sampleSetDist = SampleSetDist.t
@genType
type symbolicDist = SymbolicDistTypes.symbolicDist
@genType
type resultDist = result_<genericDist, distributionError>
@genType
type resultFloat = result_<float, distributionError>
@genType
type resultString = result_<string, distributionError>
//TODO: ForTS Interface module candid
@genType @genType
let makeSampleSetDist: array<float> => result_< let makeSampleSetDist: array<float> => result_<
sampleSetDist, sampleSetDist,
@ -55,15 +44,15 @@ type discreteShape = PointSetTypes.discreteShape
@genType @genType
type continuousShape = PointSetTypes.continuousShape type continuousShape = PointSetTypes.continuousShape
// ForTS_Distributions_Error.toString @genType
let distributionErrorToString = ForTS_Distribution_Error.toString
@genType
let defaultSamplingEnv = ForTS_Distribution.defaultEnvironment
// Umur: opaqe types
// @genType // @genType
// let distributionErrorToString = DistributionTypes.Error.toString // type declarationArg = Declaration.arg
@genType // @genType
let defaultSamplingEnv = DistributionOperation.defaultEnv // type declaration<'a> = Declaration.declaration<'a>
@genType
type declarationArg = Declaration.arg
@genType
type declaration<'a> = Declaration.declaration<'a>