@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/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: (...l: string[]) => Promise<Program>;
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
- parseProgram: (l: string[]) => Promise<{
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 {};
@@ -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: string, b: Rational) => boolean;
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;
@@ -1,4 +1,4 @@
1
- import { type ASTNode } from "./ast";
1
+ import { type ASTNode } from "./ast.js";
2
2
  /**
3
3
  * traverseAST traverses the AST.
4
4
  * @param node
@@ -1,4 +1,4 @@
1
- import { type MonoType } from "./types";
1
+ import { type MonoType } from "./types.js";
2
2
  export type TypeScheme = {
3
3
  vars: string[];
4
4
  type: MonoType;
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
@@ -1,5 +1,5 @@
1
- import { type ASTNode } from "./ast";
2
- import { type MonoType } from "./types";
1
+ import { type ASTNode } from "./ast.js";
2
+ import { type MonoType } from "./types.js";
3
3
  export declare class TypeSubstitution {
4
4
  private _current;
5
5
  constructor();
package/package.json CHANGED
@@ -1,50 +1,46 @@
1
1
  {
2
2
  "name": "@okcontract/lambdascript",
3
- "description": "lambdascript is a reactive functional scripting language",
3
+ "description": "A reactive functional scripting language",
4
4
  "private": false,
5
- "version": "0.1.0",
6
- "main": "dist/lambdascript.js",
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
- "@types/node": "^22.5.4",
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.3.3",
35
- "@okcontract/graph": "^0.1.5"
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": "npm run format && vite build",
41
- "test": "vitest run",
42
- "coverage": "vitest run --coverage",
43
- "definitions": "tsc --project tsconfig.build.json",
44
- "prepublishOnly": "npm test && npm run build && npm run check && npm run definitions",
45
- "check": "npx @biomejs/biome check src",
46
- "format": "npx @biomejs/biome format src --write && npx @biomejs/biome check src --write",
47
- "formatReadme": "prettier README.md --prose-wrap always --print-width 78 -w"
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://hbbio.github.io/lambdascript"
59
- }
57
+ "homepage": "https://github.com/okcontract/lambdascript#readme"
58
+ }