@okcontract/lambdascript 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/dist/ast.d.ts +17 -1
- package/dist/deps.d.ts +1 -1
- package/dist/env.d.ts +14 -13
- package/dist/equal.d.ts +1 -1
- package/dist/eval.d.ts +2 -2
- package/dist/find.d.ts +2 -11
- package/dist/format.d.ts +16 -0
- package/dist/highLevel.d.ts +3 -3
- package/dist/index.d.ts +17 -14
- package/dist/infer.d.ts +5 -5
- package/dist/json.d.ts +2 -2
- package/dist/lambdascript.js +4 -6865
- package/dist/lambdascript.umd.cjs +4 -1
- package/dist/lowLevel.d.ts +2 -0
- package/dist/parse.d.ts +16 -2
- package/dist/parser/index.tokens.d.ts +7 -0
- package/dist/parser//316/273s.d.ts +2 -0
- package/dist/parser//316/273s.terms.d.ts +37 -0
- package/dist/print.d.ts +2 -2
- package/dist/program.d.ts +12 -7
- package/dist/rational.d.ts +3 -1
- package/dist/singleEval.d.ts +9 -0
- package/dist/stdlib.d.ts +3 -3
- package/dist/traverse.d.ts +1 -1
- package/dist/typeScheme.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/unify.d.ts +2 -2
- package/package.json +26 -27
package/dist/program.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ASTNode } from "./ast";
|
|
2
|
-
import type { Environment } from "./env";
|
|
3
|
-
import { type ParseOptions } from "./parse";
|
|
1
|
+
import type { ASTNode } from "./ast.js";
|
|
2
|
+
import type { Environment } from "./env.js";
|
|
3
|
+
import { type ProgramComponent as ParsedProgramComponent, type ParseOptions } from "./parse.js";
|
|
4
4
|
export declare enum EvalOption {
|
|
5
5
|
NoFail = "noFail",// modified from lowercase
|
|
6
6
|
LocalEvaluation = "local",
|
|
@@ -12,6 +12,10 @@ export declare enum EvalOption {
|
|
|
12
12
|
type ProgramOptions = {
|
|
13
13
|
parseOptions?: ParseOptions;
|
|
14
14
|
};
|
|
15
|
+
export type Binding = {
|
|
16
|
+
name: string;
|
|
17
|
+
expr: ASTNode;
|
|
18
|
+
};
|
|
15
19
|
/**
|
|
16
20
|
* Program defines a lambdascript program.
|
|
17
21
|
* @usage await new Program().set([defs...])
|
|
@@ -21,6 +25,7 @@ export declare class Program {
|
|
|
21
25
|
_defs: {
|
|
22
26
|
[key: string]: ASTNode;
|
|
23
27
|
};
|
|
28
|
+
_components: ParsedProgramComponent[];
|
|
24
29
|
_options: ProgramOptions;
|
|
25
30
|
/**
|
|
26
31
|
*
|
|
@@ -32,7 +37,7 @@ export declare class Program {
|
|
|
32
37
|
private _resetProgram;
|
|
33
38
|
/** add a definition to the program, updating the graph */
|
|
34
39
|
private _addDef;
|
|
35
|
-
set: (...
|
|
40
|
+
set: (...segments: string[]) => Promise<Program>;
|
|
36
41
|
get: (key: string) => ASTNode | undefined;
|
|
37
42
|
/**
|
|
38
43
|
* order_program returns the order of evaluation for a program.
|
|
@@ -69,9 +74,9 @@ export declare class Program {
|
|
|
69
74
|
* @param l list of definitions in the form "name:expr"
|
|
70
75
|
* @returns Program (may throw error)
|
|
71
76
|
*/
|
|
72
|
-
|
|
73
|
-
[key: string]: ASTNode;
|
|
74
|
-
}>;
|
|
77
|
+
private parseProgramSegments;
|
|
75
78
|
get expressions(): string[];
|
|
79
|
+
get bindings(): readonly Binding[];
|
|
80
|
+
get components(): readonly ParsedProgramComponent[];
|
|
76
81
|
}
|
|
77
82
|
export {};
|
package/dist/rational.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare class Rational {
|
|
|
21
21
|
toString: () => string;
|
|
22
22
|
get toPrettyString(): string;
|
|
23
23
|
toBigInt: () => bigint;
|
|
24
|
+
toHex: () => `0x${string}`;
|
|
24
25
|
toNumber: () => number;
|
|
25
26
|
add: (b: Rational) => Rational;
|
|
26
27
|
subtract: (b: Rational) => Rational;
|
|
@@ -29,7 +30,7 @@ export declare class Rational {
|
|
|
29
30
|
power: (b: Rational) => Rational;
|
|
30
31
|
min: (...args: Rational[]) => Rational;
|
|
31
32
|
max: (...args: Rational[]) => Rational;
|
|
32
|
-
compare: (op:
|
|
33
|
+
compare: (op: "<" | ">" | "<=" | ">=" | "==" | "!=", b: Rational) => boolean;
|
|
33
34
|
equals: (b: Rational) => boolean;
|
|
34
35
|
floor: () => Rational;
|
|
35
36
|
}
|
|
@@ -71,3 +72,4 @@ export declare function compareRationalNumbers([aNum, aDenom, aNeg]: RationalNum
|
|
|
71
72
|
export declare function min(v: RationalNumber, ...args: RationalNumber[]): RationalNumber;
|
|
72
73
|
export declare function max(v: RationalNumber, ...args: RationalNumber[]): RationalNumber;
|
|
73
74
|
export declare const zero: Rational;
|
|
75
|
+
export declare const isRational: (v: unknown) => v is Rational;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ASTNode } from "./ast.js";
|
|
2
|
+
import type { Environment } from "./env.js";
|
|
3
|
+
import type { Value } from "./eval.js";
|
|
4
|
+
/**
|
|
5
|
+
* Evaluate an AST as a single cell by mapping once over all used
|
|
6
|
+
* environment values and library functions, then computing the value
|
|
7
|
+
* inside the mapping closure.
|
|
8
|
+
*/
|
|
9
|
+
export declare const evaluateASTSingle: (env: Environment) => (node: ASTNode) => Value<unknown>;
|
package/dist/stdlib.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SheetProxy } from "@okcontract/cells";
|
|
2
|
-
import type { Value } from "./eval";
|
|
3
|
-
import type { TypeScheme } from "./typeScheme";
|
|
4
|
-
import { type MonoType, type TypeConst } from "./types";
|
|
2
|
+
import type { Value } from "./eval.js";
|
|
3
|
+
import type { TypeScheme } from "./typeScheme.js";
|
|
4
|
+
import { type MonoType, type TypeConst } from "./types.js";
|
|
5
5
|
export declare const typeNumber: TypeConst;
|
|
6
6
|
export declare const typeString: TypeConst;
|
|
7
7
|
export declare const typeBoolean: TypeConst;
|
package/dist/traverse.d.ts
CHANGED
package/dist/typeScheme.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NameConstant, NameLambda, NameList, NameObject, NameTuple, NameVariable } from "./ast";
|
|
1
|
+
import { NameConstant, NameLambda, NameList, NameObject, NameTuple, NameVariable } from "./ast.js";
|
|
2
2
|
export declare const NameAny = "any";
|
|
3
3
|
export type MonoType = (TypeVar | TypeConst | TypeFunction | TypeList | TypeObject | TypeGeneric | TypeConditional | TypeAny | TypeTuple) & {
|
|
4
4
|
/** optional label */
|
package/dist/unify.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,50 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okcontract/lambdascript",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "A reactive functional scripting language",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.
|
|
6
|
-
"main": "dist/lambdascript.
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"main": "./dist/lambdascript.umd.cjs",
|
|
7
|
+
"module": "./dist/lambdascript.js",
|
|
7
8
|
"type": "module",
|
|
9
|
+
"packageManager": "bun@1.3.14",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
10
14
|
"import": "./dist/lambdascript.js",
|
|
11
|
-
"require": "./dist/lambdascript.umd.cjs"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
15
|
+
"require": "./dist/lambdascript.umd.cjs"
|
|
13
16
|
}
|
|
14
17
|
},
|
|
15
18
|
"files": [
|
|
16
19
|
"dist/",
|
|
17
20
|
"README.md",
|
|
18
|
-
"LICENSE"
|
|
21
|
+
"LICENSE.copying"
|
|
19
22
|
],
|
|
20
23
|
"devDependencies": {
|
|
21
|
-
"@biomejs/biome": "^1.8.3",
|
|
22
24
|
"@lezer/generator": "^1.6.0",
|
|
23
|
-
"
|
|
24
|
-
"@vitest/coverage-v8": "^2.0.5",
|
|
25
|
-
"happy-dom": "^15.7.3",
|
|
26
|
-
"immer": "^10.0.3",
|
|
27
|
-
"terser": "^5.31.6",
|
|
28
|
-
"typescript": "^5.5.4",
|
|
29
|
-
"vite": "^5.2.11",
|
|
30
|
-
"vitest": "^2.0.5"
|
|
25
|
+
"typescript": "^5.5.4"
|
|
31
26
|
},
|
|
32
27
|
"dependencies": {
|
|
28
|
+
"@lezer/common": "^1.5.2",
|
|
33
29
|
"@lezer/lr": "^1.4.2",
|
|
34
|
-
"@okcontract/cells": "^0.
|
|
35
|
-
"@okcontract/graph": "^0.
|
|
30
|
+
"@okcontract/cells": "^0.4.0",
|
|
31
|
+
"@okcontract/graph": "^0.2.0"
|
|
36
32
|
},
|
|
37
33
|
"scripts": {
|
|
38
34
|
"clean": "rm -rf dist",
|
|
39
35
|
"grammar": "lezer-generator src/parser/λs.grammar -o src/parser/λs.js",
|
|
40
|
-
"build": "
|
|
41
|
-
"test": "
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
36
|
+
"build": "bun run clean && bun run grammar && bun run format && bun build src/index.ts --outfile dist/lambdascript.js --target browser --format esm --packages external --minify && bun build src/index.ts --outfile dist/lambdascript.umd.cjs --target browser --format cjs --packages external --minify",
|
|
37
|
+
"test": "bun test --parallel",
|
|
38
|
+
"test:package": "bun scripts/package-smoke.ts",
|
|
39
|
+
"coverage": "bun test --coverage --coverage-reporter=lcov",
|
|
40
|
+
"definitions": "tsc --project tsconfig.build.json && bun scripts/fix-declaration-imports.ts",
|
|
41
|
+
"prepublishOnly": "bun run build && bun run test:package && bun run test && bun run check && bun run definitions",
|
|
42
|
+
"check": "biome check src scripts",
|
|
43
|
+
"format": "biome check src scripts --write"
|
|
48
44
|
},
|
|
49
45
|
"repository": {
|
|
50
46
|
"type": "git",
|
|
@@ -52,8 +48,11 @@
|
|
|
52
48
|
},
|
|
53
49
|
"author": "Henri Binsztok",
|
|
54
50
|
"license": "Apache-2.0",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
55
54
|
"bugs": {
|
|
56
55
|
"url": "https://github.com/okcontract/lambdascript/issues"
|
|
57
56
|
},
|
|
58
|
-
"homepage": "https://
|
|
59
|
-
}
|
|
57
|
+
"homepage": "https://github.com/okcontract/lambdascript#readme"
|
|
58
|
+
}
|