@plylang/plylang 1.0.12 → 1.0.15
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 +14 -14
- 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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plylang/plylang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
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.15",
|
|
37
|
+
"@plylang/plylang-darwin-x64": "1.0.15",
|
|
38
|
+
"@plylang/plylang-linux-arm64": "1.0.15",
|
|
39
|
+
"@plylang/plylang-linux-x64": "1.0.15",
|
|
40
|
+
"@plylang/plylang-win32-arm64": "1.0.15",
|
|
41
|
+
"@plylang/plylang-win32-x64": "1.0.15"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "cargo build --release",
|