@dallaylaen/ski-interpreter 2.1.0 → 2.2.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,43 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.2.1] - 2026-02-22
9
+
10
+ ### Added
11
+
12
+ - `Expr.diag()` outputs an expression as an indented tree (breadth-first) with class names and variables labeled for deduplication.
13
+ - `lib/ski-quest.min.js` bundle to create quest pages.
14
+ - The [playground](https://dallaylaen.github.io/ski-interpreter/playground.html) gets history!
15
+
16
+ ### Fixed
17
+
18
+ - Greatly improved type definitions.
19
+ - Quests calculate solution complexity via `fold()`.
20
+
21
+ ## [2.2.0] - 2026-02-14
22
+
23
+ ### BREAKING CHANGES
24
+
25
+ - Remove `Expr.declare()` method for good, use `toposort()` or static `declare` instead
26
+
27
+ ### Added
28
+
29
+ - `SKI.extras.toposort(list, env)` function to output named terms in dependency order
30
+ - `SKI.extras.declare(term, {env})` function for term declarations
31
+ - `Expr.unroll()` method to get a list of terms
32
+ that give the initial expression when applied
33
+ from left to right: `((a, b), (c, d)) => [a, b, (c, d)]`
34
+ - Parser: Support for chained assignments (`'foo=bar=baz'` expressions)
35
+ - Parser: Support for multi-line comment syntax (`/* comments */`)
36
+ - `SKI_REPL=1 node -r @dallaylaen/ski-interpreter` will now start a REPL with the `SKI` class available globally.
37
+
38
+ ### Changed
39
+
40
+ - Parser improvements and bug fixes for variable handling
41
+ - `expand()` method refactored to use `traverse()`
42
+ - Package now builds both CJS and ESM bundles.
43
+ - Moved source from `lib/` to `src/` directory
44
+
8
45
  ## [2.1.0] - 2026-02-12
9
46
 
10
47
  ### BREAKING CHANGES
package/README.md CHANGED
@@ -68,16 +68,19 @@ all free variables are bound.
68
68
  This page contains small tasks of increasing complexity.
69
69
  Each task requires the user to build a combinator with specific properties.
70
70
 
71
- # CLI
72
-
73
- REPL comes with the package as [bin/ski.js](bin/ski.js).
74
-
75
71
  # Installation
76
72
 
77
73
  ```bash
78
74
  npm install @dallaylaen/ski-interpreter
79
75
  ```
80
76
 
77
+ # CLI
78
+
79
+ REPL comes with the package as [bin/ski.js](bin/ski.js).
80
+
81
+ Running `SKI_REPL=1 node -r @dallaylaen/ski-interpreter/bin/ski.js`
82
+ will start a node shell with the `SKI` class available as a global variable.
83
+
81
84
  # Usage
82
85
 
83
86
  ## A minimal example
@@ -147,7 +150,11 @@ const lambdaSteps = [...skiExpr.toLambda()];
147
150
  ## Fancy formatting
148
151
 
149
152
  The `format` methods of the `Expr` class supports
150
- a number of options, see [the source code](lib/expr.js) for details.
153
+ a number of options, see [the source code](src/expr.js) for details.
154
+
155
+ `expr.diag()` will instead output indented
156
+ expression tree (breadth-first) with class information
157
+ and variables labeled for disambiguation.
151
158
 
152
159
  ## Variable scoping
153
160
 
@@ -183,6 +190,9 @@ expr.traverse(e => e.equals(SKI.I) ? SKI.S.apply(SKI.K, SKI.K) : null);
183
190
  // replaces all I's with S K K
184
191
  // here a returned `Expr` object replaces the subexpression,
185
192
  // whereas `null` means "leave it alone and descend if possible"
193
+
194
+ expr.fold(0, (acc, e) => acc + (e.equals(SKI.K) ? acc+1 : acc));
195
+ // counts the number of K's in the expression
186
196
  ```
187
197
 
188
198
  ## Test cases
@@ -209,6 +219,17 @@ q.check('K(K(y x))') // nope! the variable scopes won't match
209
219
 
210
220
  See [quest page data](docs/quest-data/) for more examples.
211
221
 
222
+ # Package contents
223
+
224
+ * `lib/ski-interpreter.cjs.js` - main entry point for Node.js;
225
+ * `lib/ski-interpreter.esm.js` - main entry point for ES modules;
226
+ * `lib/ski-interpreter.min.js` - minified version for browsers;
227
+ * `lib/ski-quest.min.js` - script with the interpreter
228
+ plus `QuestBox`, `QuestChapter`, and `QuestPage` classes
229
+ for building interactive quest pages from JSON-encoded quest data;
230
+ * `bin/ski.js` - a CLI REPL;
231
+ * `types` - TypeScript type definitions.
232
+
212
233
  # Thanks
213
234
 
214
235
  * [@ivanaxe](https://github.com/ivanaxe) for luring me into [icfpc 2011](http://icfpc2011.blogspot.com/2011/06/task-description-contest-starts-now.html) where I was introduced to combinators.
package/bin/ski.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fs = require('node:fs/promises');
4
4
 
5
- const { SKI } = require('../index');
5
+ const { SKI } = require('../lib/ski-interpreter.cjs');
6
6
 
7
7
  const [myname, options, positional] = parseArgs(process.argv);
8
8