more typescript friendly & remove an unnecessary call
This commit is contained in:
parent
966fc7ad98
commit
ee17bd9e57
|
@ -10,8 +10,8 @@ module ProjectItem = ReducerProject_ProjectItem
|
||||||
module T = ReducerProject_T
|
module T = ReducerProject_T
|
||||||
module Topology = ReducerProject_Topology
|
module Topology = ReducerProject_Topology
|
||||||
|
|
||||||
@genType.opaque
|
|
||||||
type project = T.t
|
type project = T.t
|
||||||
|
@genType.opaque
|
||||||
type t = T.t
|
type t = T.t
|
||||||
|
|
||||||
module Private = {
|
module Private = {
|
||||||
|
@ -27,6 +27,7 @@ module Private = {
|
||||||
|
|
||||||
let createProject = () => {
|
let createProject = () => {
|
||||||
let this: t = {
|
let this: t = {
|
||||||
|
"tag": "reducerProject",
|
||||||
"items": Belt.Map.String.empty,
|
"items": Belt.Map.String.empty,
|
||||||
"stdLib": ReducerInterface_StdLib.internalStdLib,
|
"stdLib": ReducerInterface_StdLib.internalStdLib,
|
||||||
"environment": InternalExpressionValue.defaultEnvironment,
|
"environment": InternalExpressionValue.defaultEnvironment,
|
||||||
|
@ -226,30 +227,38 @@ To run a group of source codes and get results/bindings, the necessary methods a
|
||||||
- run or runAll
|
- run or runAll
|
||||||
- getExternalBindings
|
- getExternalBindings
|
||||||
- getExternalResult
|
- getExternalResult
|
||||||
|
|
||||||
|
A project has a public field tag with a constant value "reducerProject"
|
||||||
|
project = {tag: "reducerProject"}
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let createProject = (): t => Private.createProject()->T.Private.castFromInternalProject
|
let createProject = (): t => Private.createProject()->T.Private.castFromInternalProject
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Answer all the source ids of all the sources in the project.
|
Answer all the source ids of all the sources in the project.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getSourceIds = (this: t): array<string> =>
|
let getSourceIds = (this: t): array<string> =>
|
||||||
this->T.Private.castToInternalProject->Private.getSourceIds
|
this->T.Private.castToInternalProject->Private.getSourceIds
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sets the source for a given source Id.
|
Sets the source for a given source Id.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let setSource = (this: t, sourceId: string, value: string): unit =>
|
let setSource = (this: t, sourceId: string, value: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.setSource(sourceId, value)
|
this->T.Private.castToInternalProject->Private.setSource(sourceId, value)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gets the source for a given source id.
|
Gets the source for a given source id.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getSource = (this: t, sourceId: string): option<string> =>
|
let getSource = (this: t, sourceId: string): option<string> =>
|
||||||
this->T.Private.castToInternalProject->Private.getSource(sourceId)
|
this->T.Private.castToInternalProject->Private.getSource(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Touches the source for a given source id. This and dependent, sources are set to be re-evaluated.
|
Touches the source for a given source id. This and dependent, sources are set to be re-evaluated.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let touchSource = (this: t, sourceId: string): unit =>
|
let touchSource = (this: t, sourceId: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.touchSource(sourceId)
|
this->T.Private.castToInternalProject->Private.touchSource(sourceId)
|
||||||
|
|
||||||
|
@ -258,36 +267,44 @@ Cleans the compilation artifacts for a given source ID. The results stay untouch
|
||||||
|
|
||||||
Normally, you would never need the compilation artifacts again as the results with the same sources would never change. However, they are needed in case of any debugging reruns
|
Normally, you would never need the compilation artifacts again as the results with the same sources would never change. However, they are needed in case of any debugging reruns
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let clean = (this: t, sourceId: string): unit =>
|
let clean = (this: t, sourceId: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.clean(sourceId)
|
this->T.Private.castToInternalProject->Private.clean(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cleans all the compilation artifacts in all of the project
|
Cleans all the compilation artifacts in all of the project
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let cleanAll = (this: t): unit => this->T.Private.castToInternalProject->Private.cleanAll
|
let cleanAll = (this: t): unit => this->T.Private.castToInternalProject->Private.cleanAll
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cleans results. Compilation stays untouched to be able to re-run the source.
|
Cleans results. Compilation stays untouched to be able to re-run the source.
|
||||||
You would not do this if you were not trying to debug the source code.
|
You would not do this if you were not trying to debug the source code.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let cleanResults = (this: t, sourceId: string): unit =>
|
let cleanResults = (this: t, sourceId: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.cleanResults(sourceId)
|
this->T.Private.castToInternalProject->Private.cleanResults(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cleans all results. Compilations remains untouched to rerun the source.
|
Cleans all results. Compilations remains untouched to rerun the source.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let cleanAllResults = (this: t): unit =>
|
let cleanAllResults = (this: t): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.cleanAllResults
|
this->T.Private.castToInternalProject->Private.cleanAllResults
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
let getIncludes = (this: t, sourceId: string): ProjectItem.T.includesType =>
|
@genType
|
||||||
this->T.Private.castToInternalProject->Private.getIncludes(sourceId)
|
let getIncludes = (this: t, sourceId: string): result<
|
||||||
|
array<string>,
|
||||||
|
Reducer_ErrorValue.errorValue,
|
||||||
|
> => this->T.Private.castToInternalProject->Private.getIncludes(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Answers the source codes after which this source code is continuing
|
Answers the source codes after which this source code is continuing
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getContinues = (this: t, sourceId: string): array<string> =>
|
let getContinues = (this: t, sourceId: string): array<string> =>
|
||||||
this->T.Private.castToInternalProject->Private.getContinues(sourceId)
|
this->T.Private.castToInternalProject->Private.getContinues(sourceId)
|
||||||
|
|
||||||
|
@ -296,35 +313,35 @@ let getContinues = (this: t, sourceId: string): array<string> =>
|
||||||
It is used to define a continuation that is not visible in the source code.
|
It is used to define a continuation that is not visible in the source code.
|
||||||
You can chain source codes on the web interface for example
|
You can chain source codes on the web interface for example
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let setContinues = (this: t, sourceId: string, continues: array<string>): unit =>
|
let setContinues = (this: t, sourceId: string, continues: array<string>): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.setContinues(sourceId, continues)
|
this->T.Private.castToInternalProject->Private.setContinues(sourceId, continues)
|
||||||
|
|
||||||
/*
|
|
||||||
Break the continuation chain. This source will become a standalone source.
|
|
||||||
*/
|
|
||||||
let removeContinues = (this: t, sourceId: string): unit =>
|
|
||||||
this->T.Private.castToInternalProject->Private.removeContinues(sourceId)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This source depends on the array of sources returned.
|
This source depends on the array of sources returned.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getDependencies = (this: t, sourceId: string): array<string> =>
|
let getDependencies = (this: t, sourceId: string): array<string> =>
|
||||||
this->T.Private.castToInternalProject->Private.getDependencies(sourceId)
|
this->T.Private.castToInternalProject->Private.getDependencies(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The sources returned are dependent on this
|
The sources returned are dependent on this
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getDependents = (this: t, sourceId: string): array<string> =>
|
let getDependents = (this: t, sourceId: string): array<string> =>
|
||||||
this->T.Private.castToInternalProject->Private.getDependents(sourceId)
|
this->T.Private.castToInternalProject->Private.getDependents(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get the run order for the sources in the project.
|
Get the run order for the sources in the project.
|
||||||
*/
|
*/
|
||||||
let getRunOrder = (this: t) => this->T.Private.castToInternalProject->Private.getRunOrder
|
@genType
|
||||||
|
let getRunOrder = (this: t): array<string> =>
|
||||||
|
this->T.Private.castToInternalProject->Private.getRunOrder
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get the run order to get the results of this specific source
|
Get the run order to get the results of this specific source
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getRunOrderFor = (this: t, sourceId: string) =>
|
let getRunOrderFor = (this: t, sourceId: string) =>
|
||||||
this->T.Private.castToInternalProject->Private.getRunOrderFor(sourceId)
|
this->T.Private.castToInternalProject->Private.getRunOrderFor(sourceId)
|
||||||
|
|
||||||
|
@ -333,6 +350,7 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let parseIncludes = (this: t, sourceId: string): unit =>
|
let parseIncludes = (this: t, sourceId: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.parseIncludes(sourceId)
|
this->T.Private.castToInternalProject->Private.parseIncludes(sourceId)
|
||||||
|
|
||||||
|
@ -341,29 +359,34 @@ Parse the source code if it is not done already.
|
||||||
Use getRawParse to get the parse tree.
|
Use getRawParse to get the parse tree.
|
||||||
You would need this function if you want to see the parse tree without running the source code.
|
You would need this function if you want to see the parse tree without running the source code.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let rawParse = (this: t, sourceId: string): unit =>
|
let rawParse = (this: t, sourceId: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.rawParse(sourceId)
|
this->T.Private.castToInternalProject->Private.rawParse(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Runs a specific source code if it is not done already. The code is parsed if it is not already done. It runs the dependencies if it is not already done.
|
Runs a specific source code if it is not done already. The code is parsed if it is not already done. It runs the dependencies if it is not already done.
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let run = (this: t, sourceId: string): unit =>
|
let run = (this: t, sourceId: string): unit =>
|
||||||
this->T.Private.castToInternalProject->Private.run(sourceId)
|
this->T.Private.castToInternalProject->Private.run(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Runs all of the sources in a project. Their results and bindings will be available
|
Runs all of the sources in a project. Their results and bindings will be available
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let runAll = (this: t): unit => this->T.Private.castToInternalProject->Private.runAll
|
let runAll = (this: t): unit => this->T.Private.castToInternalProject->Private.runAll
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get the bindings after running this source file or the project
|
Get the bindings after running this source file or the project
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getExternalBindings = (this: t, sourceId: string): ExternalExpressionValue.record =>
|
let getExternalBindings = (this: t, sourceId: string): ExternalExpressionValue.record =>
|
||||||
this->T.Private.castToInternalProject->Private.getExternalBindings(sourceId)
|
this->T.Private.castToInternalProject->Private.getExternalBindings(sourceId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get the result after running this source file or the project
|
Get the result after running this source file or the project
|
||||||
*/
|
*/
|
||||||
|
@genType
|
||||||
let getExternalResult = (this: t, sourceId: string): option<
|
let getExternalResult = (this: t, sourceId: string): option<
|
||||||
result<ExternalExpressionValue.t, Reducer_ErrorValue.errorValue>,
|
result<ExternalExpressionValue.t, Reducer_ErrorValue.errorValue>,
|
||||||
> => this->T.Private.castToInternalProject->Private.getExternalResult(sourceId)
|
> => this->T.Private.castToInternalProject->Private.getExternalResult(sourceId)
|
||||||
|
@ -373,6 +396,7 @@ 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) => {
|
let evaluate = (sourceCode: string): ('r, 'b) => {
|
||||||
let (result, continuation) = Private.evaluate(sourceCode)
|
let (result, continuation) = Private.evaluate(sourceCode)
|
||||||
(
|
(
|
||||||
|
@ -381,6 +405,7 @@ let evaluate = (sourceCode: string): ('r, 'b) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@genType
|
||||||
let foreignFunctionInterface = (
|
let foreignFunctionInterface = (
|
||||||
lambdaValue: ExternalExpressionValue.lambdaValue,
|
lambdaValue: ExternalExpressionValue.lambdaValue,
|
||||||
argArray: array<ExternalExpressionValue.t>,
|
argArray: array<ExternalExpressionValue.t>,
|
||||||
|
|
|
@ -2,11 +2,12 @@ module ProjectItem = ReducerProject_ProjectItem
|
||||||
module ExpressionT = Reducer_Expression_T
|
module ExpressionT = Reducer_Expression_T
|
||||||
module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
|
module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
|
||||||
|
|
||||||
type project = Object
|
type project = {"tag": string}
|
||||||
type t = project
|
type t = project
|
||||||
|
|
||||||
module Private = {
|
module Private = {
|
||||||
type internalProject = {
|
type internalProject = {
|
||||||
|
"tag": string,
|
||||||
"items": Belt.Map.String.t<ProjectItem.t>,
|
"items": Belt.Map.String.t<ProjectItem.t>,
|
||||||
"stdLib": Reducer_Bindings.t,
|
"stdLib": Reducer_Bindings.t,
|
||||||
"environment": ExpressionT.environment,
|
"environment": ExpressionT.environment,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user