@plylang/plylang 1.0.20 → 1.0.22

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.
Files changed (2) hide show
  1. package/README.md +9 -7
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -131,7 +131,7 @@ When the first line of a body is patterns and `->`, the whole body is equations.
131
131
 
132
132
  `true` together with `false` covers `Bool`. `Num`, `Int`, and `Str` need a final branch with a name or `_`.
133
133
 
134
- A bare constructor puts its fields on the stack from left to right, the last field on top. Parentheses hold one slot: `(Just x)` names the field and does not put it until the name is mentioned. `(Person n _)` names the first field of `Person` and discards the second.
134
+ A bare constructor checks the tag and leaves the value. `(Ctor ..)` spills every field, last on top. `(Just x)` names the one field and does not put it until the name is mentioned. `(Person n _)` is positional: the first field is kept under `n` and the second is discarded. `(Person age name)` binds by name, in either order, when every name is a field. `(Person)` is an error. `(Some (Array Num) items)` checks that the field is an array of numbers and names that array. The check runs when the field's type is still open. `(Some (Array Num))` without a name is an error. `(Some (Num) ..)` checks and spills that number. `(Some (Num) _)` only checks.
135
135
 
136
136
  An array in a pattern has a fixed length. `<>` matches only the empty array. One length does not cover every `Array`.
137
137
 
@@ -149,15 +149,15 @@ An array in a pattern has a fixed length. `<>` matches only the empty array. One
149
149
  ; Maybe a = Nothing | Just a
150
150
 
151
151
  : fromMaybe ( a (Maybe a) -- a )
152
- Nothing ->
153
- Just -> nip
152
+ (Nothing ..) ->
153
+ (Just ..) -> nip
154
154
 
155
155
  : mapMaybe ( (Maybe a) (a -- b) -- (Maybe b) )
156
- Nothing q -> q drop Nothing
156
+ (Nothing ..) q -> q drop Nothing
157
157
  (Just x) q -> x q call Just
158
158
  ```
159
159
 
160
- The empty body of the `Nothing` branch leaves the fallback value. For `Just` the field lands above it, and `nip` drops what is underneath. In `mapMaybe` the quotation is the top: `q` names it, and `(Just x)` names the field.
160
+ The empty body of the `(Nothing ..)` branch leaves the fallback value. For `Just`, `(Just ..)` puts the field above it, and `nip` drops what is underneath. In `mapMaybe` the quotation is the top: `q` names it, and `(Just x)` names the field. A bare `Just` would leave the `Maybe` in place.
161
161
 
162
162
  A list with its own structure is a separate type. The head sits in the constructor, and the tail is another value of that type.
163
163
 
@@ -165,6 +165,8 @@ A list with its own structure is a separate type. The head sits in the construct
165
165
  ; List a = Nil | Cons head : a, tail : (List a)
166
166
  ```
167
167
 
168
+ A `|` may stand before the first constructor, so every arm starts in the same column.
169
+
168
170
  Zero fields and one field have no names. `Nothing` stores nothing. `Just a` stores one value, and the equation names it. Two or more fields are `name : Type`, separated by commas. A second positional type is [PL0117](docs/Errors.md#pl0117). One named field is [PL0118](docs/Errors.md#pl0118).
169
171
 
170
172
  ```ply
@@ -177,7 +179,7 @@ Zero fields and one field have no names. `Nothing` stores nothing. `Just a` stor
177
179
  >>snd
178
180
  ```
179
181
 
180
- `Pair` the word takes the fields in that order, last on top. `frs>>` consumes the pair and leaves the field. When the pair is still needed, copy it first: `dup frs>>`. `>>snd` takes the new field above the pair and returns a new pair. The previous pair is a separate value. A sum has no reader: `->` picks the constructor. `name>>` on `Maybe` is [PL0119](docs/Errors.md#pl0119). `frs>>` on `Int`, on a type variable, or on a synonym of `Num` is [PL0063](docs/Errors.md#pl0063). A missing field is [PL0120](docs/Errors.md#pl0120).
182
+ `Pair` the word takes the fields in that order, last on top. `frs>>` consumes the pair and leaves the field. When the pair is still needed, copy it first: `dup frs>>`. `>>snd` takes the new field above the pair and returns a new pair. The previous pair is a separate value. A field on every constructor, with the same type, is `name>>`. A field of one constructor is read after that constructor's check: `Sent -> body>>`. `name>>` on `Maybe` is [PL0119](docs/Errors.md#pl0119). `frs>>` on `Int`, on a type variable, or on a synonym of `Num` is [PL0063](docs/Errors.md#pl0063). A missing field is [PL0120](docs/Errors.md#pl0120). `(Page)` is [PL0136](docs/Errors.md#pl0136).
181
183
 
182
184
  In JavaScript a constructor with no fields is `{ tag: "Nothing" }`. One field is `(value) => ({ tag: "Just", value })`. Named fields are properties: `(v0, v1) => ({ tag: "Pair", frs: v0, snd: v1 })`.
183
185
 
@@ -224,7 +226,7 @@ Parameters are written as they are on a type: `- Twin a (Pair a a)`. In a slot a
224
226
  ; Age == Age Num
225
227
 
226
228
  : older ( Age -- Age )
227
- Age -> 1 add Age
229
+ (Age ..) -> 1 add Age
228
230
  ```
229
231
 
230
232
  Zero fields, two fields, or two constructors do not fit `==`. A type with `=` is for those.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plylang/plylang",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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.20",
37
- "@plylang/plylang-darwin-x64": "1.0.20",
38
- "@plylang/plylang-linux-arm64": "1.0.20",
39
- "@plylang/plylang-linux-x64": "1.0.20",
40
- "@plylang/plylang-win32-arm64": "1.0.20",
41
- "@plylang/plylang-win32-x64": "1.0.20"
36
+ "@plylang/plylang-darwin-arm64": "1.0.22",
37
+ "@plylang/plylang-darwin-x64": "1.0.22",
38
+ "@plylang/plylang-linux-arm64": "1.0.22",
39
+ "@plylang/plylang-linux-x64": "1.0.22",
40
+ "@plylang/plylang-win32-arm64": "1.0.22",
41
+ "@plylang/plylang-win32-x64": "1.0.22"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "cargo build --release",