@plylang/plylang 1.0.11 → 1.0.14
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 +17 -16
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ The repository contains the `plylang` compiler and the `plylang-ls` server. Word
|
|
|
13
13
|
A signature says what a word takes and what it puts. The tail under that prefix stays in place.
|
|
14
14
|
|
|
15
15
|
```ply
|
|
16
|
-
~ "Num"
|
|
16
|
+
~ "Num" add
|
|
17
17
|
|
|
18
18
|
: double ( Num -- Num )
|
|
19
19
|
dup add
|
|
@@ -95,7 +95,7 @@ The same permutations as in Factor follow, with names made of letters: `dupd`, `
|
|
|
95
95
|
`cons` pushes a value and then runs a quotation. The value sits under the quotation, so `5 [ 1 add ] cons` is a quotation of type `(-- Num)` that pushes five and then adds one. The call site does not name that value.
|
|
96
96
|
|
|
97
97
|
```ply
|
|
98
|
-
~ "Num"
|
|
98
|
+
~ "Num" eq, sub, mul
|
|
99
99
|
|
|
100
100
|
: fact ( Num -- Num )
|
|
101
101
|
dup 0 eq [ drop 1 ] [ dup 1 sub fact mul ] if
|
|
@@ -184,15 +184,15 @@ In JavaScript a constructor with no fields is `{ tag: "Nothing" }`. One field is
|
|
|
184
184
|
A word that walks an array is imported. In the example the quotation sits on top. The name comes from one module, and the instance for the array comes from another.
|
|
185
185
|
|
|
186
186
|
```ply
|
|
187
|
-
~ "Map"
|
|
188
|
-
~ "Num"
|
|
189
|
-
~ "Arr"
|
|
187
|
+
~ "Map" map
|
|
188
|
+
~ "Num" add
|
|
189
|
+
~ "Arr"
|
|
190
190
|
|
|
191
191
|
: shifted ( -- (Array Num) )
|
|
192
192
|
< 1 2 3 > [ 1 add ] map
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
The bare import of `Arr` brings the instances of that module and brings no names. The result is `2`, `3`, `4`.
|
|
196
196
|
|
|
197
197
|
## A name for a type
|
|
198
198
|
|
|
@@ -213,7 +213,7 @@ Parameters are written as they are on a type: `- Twin a (Pair a a)`. In a slot a
|
|
|
213
213
|
`;` with `==` is a distinct type with one constructor and one field. It does not unify with the field. In JavaScript the constructor returns its argument as it is.
|
|
214
214
|
|
|
215
215
|
```ply
|
|
216
|
-
~ "Num"
|
|
216
|
+
~ "Num" add
|
|
217
217
|
|
|
218
218
|
; Age == Age Num
|
|
219
219
|
|
|
@@ -228,7 +228,7 @@ Zero fields, two fields, or two constructors do not fit `==`. A type with `=` is
|
|
|
228
228
|
`(StrMap a)` is a dictionary with key `Str`. The key becomes known at run time and is not named in the type ahead of time. There is no literal. An empty dictionary in JavaScript is `Object.create(null)`.
|
|
229
229
|
|
|
230
230
|
```ply
|
|
231
|
-
~ "Dict"
|
|
231
|
+
~ "Dict" empty, put
|
|
232
232
|
|
|
233
233
|
: ages ( -- (StrMap Num) )
|
|
234
234
|
empty "Ada" 36 put
|
|
@@ -249,14 +249,14 @@ The order in the example is the dictionary, the key, and the value on top.
|
|
|
249
249
|
```
|
|
250
250
|
|
|
251
251
|
```ply
|
|
252
|
-
~ "Equal"
|
|
253
|
-
~ "Num"
|
|
252
|
+
~ "Equal" Equal, eq
|
|
253
|
+
~ "Num"
|
|
254
254
|
|
|
255
255
|
: same ( Equal a => a a -- Bool )
|
|
256
256
|
eq
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
The instance for numbers is declared in the `Num` module. `
|
|
259
|
+
The instance for numbers is declared in the `Num` module. The bare import of `Num` brings the instances of that module and brings no names. That import gives `same` that instance.
|
|
260
260
|
|
|
261
261
|
A hand-written instance is a word for each method. A module may write one when it defines the class, the type, or the wrapper in the head, or when the head contains a built-in constructor `Int`, `Num`, `Bool`, `Str`, `Unit`, `Array`, or `StrMap`.
|
|
262
262
|
|
|
@@ -293,13 +293,13 @@ One `*.ply` file is one module. The file itself has no name. The path from the s
|
|
|
293
293
|
A module names what it publishes with one `@` list. The list may stand anywhere in the file. A name in the list leaves the file. Any other name stays in the file. The same list holds words, types, constructors, synonyms, classes, methods, and names brought in by an import. A type and its constructor share one entry when they share a name. Names are separated by commas. A bare `@` publishes nothing. A second `@` is a duplicate definition.
|
|
294
294
|
|
|
295
295
|
```ply
|
|
296
|
-
~ "Data/Maybe"
|
|
297
|
-
~ "@algosail/example/Num"
|
|
296
|
+
~ "Data/Maybe" Just, Nothing, fromMaybe
|
|
297
|
+
~ "@algosail/example/Num" add
|
|
298
298
|
|
|
299
299
|
@ Maybe, Nothing, Just, fromMaybe
|
|
300
300
|
```
|
|
301
301
|
|
|
302
|
-
Imports stay together and come before the first `:`, `;`, `-`, `&`, or `#`. A path inside this package is written from the source directory. A path into another package is a package specifier. The
|
|
302
|
+
Imports stay together and come before the first `:`, `;`, `-`, `&`, or `#`. A path inside this package is written from the source directory. A path into another package is a package specifier. The names after the path are what this file uses. `: Alias` brings every published name as `Alias:name`, and a call is `Alias:send`. `send : busSend` brings `send` as `busSend`. A bare path brings instances and no names. Writing the local name again in the `@` list publishes it. A colon in column 0 still starts a word.
|
|
303
303
|
|
|
304
304
|
A test entry, a word `( -- Verdict )` or `suite`, is not a module and has no list. A utility under `test/` is a module and has one. A word `main` with scheme `( -- Unit )` may stay off the list. Node still runs it when it starts that file.
|
|
305
305
|
|
|
@@ -329,11 +329,12 @@ A `foreign` word has no body. Its implementation lives in the foreign directory,
|
|
|
329
329
|
: foreign length ( (Array a) -- Num )
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
The foreign directory is `foreign` when that directory exists, or the string `ply.foreign` when the field is set. It is required when the package has such a word. It lies inside the package and is distinct from the source directory and the output directory. The generated `.js` imports the implementation from there. Those files are not copied into `dist`. A new package writes `ply.language` and leaves `source`, `foreign`, and `out` unset: those directories are `src`, `foreign`, and `dist`. `ply.entry` names the module a pathless package import opens, and the `exports` key `.`.
|
|
332
|
+
The foreign directory is `foreign` when that directory exists, or the string `ply.foreign` when the field is set. It is required when the package has such a word. It lies inside the package and is distinct from the source directory and the output directory. The generated `.js` imports the implementation from there. Those files are not copied into `dist`. A new package writes `ply.language` and leaves `source`, `foreign`, and `out` unset: those directories are `src`, `foreign`, and `dist`. `ply.entry` names the module a pathless package import opens, and the `exports` key `.`. `plylang compile` writes `script.js` in the output directory: one classic script for a page. It inlines the bindings `main` reaches and calls `main()` at the end. That module is `ply.entry`, and `main` has scheme `( -- Unit )`.
|
|
333
333
|
|
|
334
334
|
```text
|
|
335
335
|
plylang check [dir]
|
|
336
336
|
plylang build [dir] [--exports]
|
|
337
|
+
plylang compile [dir]
|
|
337
338
|
plylang test [pattern]
|
|
338
339
|
plylang docs [dir] [--out <file>]
|
|
339
340
|
plylang check --parse <file>
|
|
@@ -344,7 +345,7 @@ plylang check --js <file>
|
|
|
344
345
|
|
|
345
346
|
`plylang test` builds the package, then compiles and runs the files that match one pattern. The pattern is relative to the package root. The default is `test/**/*.ply`. `*` matches inside one path segment. `**` matches across directories. Quote the pattern so the shell does not expand `*`. A test is a word `( -- Verdict )`. The runner calls each one in source order and uses the word as its name. `expect` compares two values. `pass` and `differ` build a verdict when those values have no `Showable` instance. The words live in `@plylang/test`. A file with no such word may export `suite` with scheme `( -- (Array Verdict) )` instead. A file under `test/` with neither is a utility. A test imports it by its path under `test/`, and a source file cannot. The runner does not run a utility. A source file cannot import a package that is only a `devDependency`. A test can. A file under the source directory stays where `build` wrote it. Any other test file is compiled in that package, written under the output directory for the run, and deleted afterwards. The report names each file and each check. A check also prints `file:line` of its word. A failing check prints its text under the name. One check that throws still lets the other checks run. A file that does not compile or does not run prints the diagnostic, and the other files still run. A failed check, a compile error, or a thrown suite exits 1. No file matched exits 1 with `no tests matched`. Color is used when stdout is a terminal and `NO_COLOR` is unset.
|
|
346
347
|
|
|
347
|
-
A word named `main` whose scheme is `( -- Unit )` is the program of that module. It may stay off the `@` list. `build` calls it at the bottom of that module's `.js`, and only when Node started that file. `node dist/App.js` runs the program. An import of the module does not. A `package.json` script can name that file. Several modules may each have a `main`. A module without one is a library. Any other scheme on the name `main` is an error.
|
|
348
|
+
A word named `main` whose scheme is `( -- Unit )` is the program of that module. It may stay off the `@` list. `build` calls it at the bottom of that module's `.js`, and only when Node started that file. `node dist/App.js` runs the program. An import of the module does not. A `package.json` script can name that file. Several modules may each have a `main`. A module without one is a library. Any other scheme on the name `main` is an error. `plylang compile` also writes those modules, then `script.js` beside them. The file is the program of `ply.entry`. A binding is inlined when `main` can call it. The modules themselves still carry the Node guard. `compile` does not rewrite `exports`.
|
|
348
349
|
|
|
349
350
|
`plylang docs` writes `DOCS.md` at the package root. `--out` names another file. A module heading is the string used to import it: the package name and the path, or only the path when there is no name. The prose comes from `..`. Inside a module the sections are `Types`, `Classes`, `Instances`, and `Words`. An empty section is left out. The name of a type, a class, or a word is a heading under its section. `Instances` is a list of `#` heads, with no comment and no method bindings.
|
|
350
351
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plylang/plylang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Ply compiler and language server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Algosail",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"bin/native.js"
|
|
34
34
|
],
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@plylang/plylang-darwin-arm64": "1.0.
|
|
37
|
-
"@plylang/plylang-darwin-x64": "1.0.
|
|
38
|
-
"@plylang/plylang-linux-arm64": "1.0.
|
|
39
|
-
"@plylang/plylang-linux-x64": "1.0.
|
|
40
|
-
"@plylang/plylang-win32-arm64": "1.0.
|
|
41
|
-
"@plylang/plylang-win32-x64": "1.0.
|
|
36
|
+
"@plylang/plylang-darwin-arm64": "1.0.14",
|
|
37
|
+
"@plylang/plylang-darwin-x64": "1.0.14",
|
|
38
|
+
"@plylang/plylang-linux-arm64": "1.0.14",
|
|
39
|
+
"@plylang/plylang-linux-x64": "1.0.14",
|
|
40
|
+
"@plylang/plylang-win32-arm64": "1.0.14",
|
|
41
|
+
"@plylang/plylang-win32-x64": "1.0.14"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "cargo build --release",
|