squiggle/packages/squiggle-lang/src/js/index.ts

37 lines
1.1 KiB
TypeScript
Raw Normal View History

import { environment } from "../rescript/ForTS/ForTS__Types.gen";
2022-08-28 16:19:44 +00:00
import { SqProject } from "./SqProject";
import { SqValue, SqValueTag } from "./SqValue";
export { SqValueLocation } from "./SqValueLocation";
2022-08-27 17:46:43 +00:00
export { result } from "../rescript/ForTS/ForTS_Result_tag";
2022-08-28 16:19:44 +00:00
export { SqDistribution, SqDistributionTag } from "./SqDistribution";
export { SqDistributionError } from "./SqDistributionError";
export { SqRecord } from "./SqRecord";
export { SqLambda } from "./SqLambda";
export { SqProject };
export { SqValue, SqValueTag };
2022-08-27 17:46:43 +00:00
export {
environment,
defaultEnvironment,
2022-08-27 17:46:43 +00:00
} from "../rescript/ForTS/ForTS_Distribution/ForTS_Distribution.gen";
2022-08-28 16:19:44 +00:00
export { SqError } from "./SqError";
export { SqShape } from "./SqPointSetDist";
2022-08-28 16:19:44 +00:00
export { resultMap } from "./types";
2022-08-19 16:28:19 +00:00
2022-08-27 17:46:43 +00:00
export const run = (
code: string,
options?: {
environment?: environment;
}
) => {
2022-08-28 16:19:44 +00:00
const project = SqProject.create();
2022-08-27 17:46:43 +00:00
project.setSource("main", code);
if (options?.environment) {
project.setEnvironment(options.environment);
}
project.run("main");
const result = project.getResult("main");
const bindings = project.getBindings("main");
return { result, bindings };
};