@fraczak/k 4.0.3 → 4.0.4
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 +158 -154
- package/k-repl.cast +1913 -0
- package/k-repl.cast~ +1939 -0
- package/k.cast +618 -0
- package/package.json +1 -1
- package/repl.mjs +2 -3
- package/run.mjs +3 -1
- package/TYPES.md +0 -32
- package/demo.cast +0 -1772
- package/demo.gif +0 -0
- package/demo2.cast +0 -1705
- package/demo_optimized.gif +0 -0
- package/sc.py +0 -25
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# k-language
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```sh
|
|
4
|
+
npm i '@fraczak/k'
|
|
5
|
+
```
|
|
4
6
|
|
|
5
7
|
From javascript:
|
|
6
8
|
|
|
7
|
-
```
|
|
9
|
+
```javascript
|
|
8
10
|
import k from "@fraczak/k"
|
|
9
11
|
|
|
10
12
|
const fn = k.compile(` -- complete "pure" k-program
|
|
@@ -16,39 +18,11 @@ const three = {i:{i:{i:{o:{}}}}};
|
|
|
16
18
|
const six = fn(three);
|
|
17
19
|
console.log(JSON.stringify( six ));
|
|
18
20
|
// {"i":{"i":{"i":{"i":{"i":{"i":{"o":{}}}}}}}}
|
|
19
|
-
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
Working with REPL:
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
$ k-repl
|
|
26
|
-
Very! experimental repl shell for 'k-language'...
|
|
27
|
-
--c print aliased codes
|
|
28
|
-
--C code print 'code' definition
|
|
29
|
-
--r print relations
|
|
30
|
-
--R rel print 'rel' definition with type patterns
|
|
31
|
-
--p (--pp) pretty-print last value
|
|
32
|
-
--s (--g) reg store (get) the current value in (from) register 'reg'
|
|
33
|
-
--regs print register names
|
|
34
|
-
--l file.k load 'file.k'
|
|
35
|
-
> -- DEMO: comments start with '--', like this line \
|
|
36
|
-
-- Code (type) definitions: ` $ code-name = code-expression ;` \
|
|
37
|
-
$ unit = { } ; -- empty product code \
|
|
38
|
-
$ bits = <unit _, bits 0, bits 1>; -- union, 3 variants tagged: _, 0, 1 \
|
|
39
|
-
-- Now, we will define relations: ` name = expression ; ` \
|
|
40
|
-
empty = {{} _} ; -- alternative JSON-like syntax {_: {}} allowed \
|
|
41
|
-
_001 = {0: {0: {1: empty}}}; -- in JSON-like syntax \
|
|
42
|
-
reverse_ = < -- priority merge \
|
|
43
|
-
{.in.0 in, {.out 0} out} reverse_, \
|
|
44
|
-
{.in.1 in, {.out 1} out} reverse_, \
|
|
45
|
-
.out >; \
|
|
46
|
-
reverse = {() in, empty out} reverse_ ; \
|
|
47
|
-
_001 reverse -- run the expression (composition of 2 relations)
|
|
48
|
-
--> {"1":{"0":{"0":{"_":{}}}}}
|
|
49
|
-
> toStr = < .0 ["0",toStr] CONCAT, .1 ["1",toStr] CONCAT, "" >; toStr
|
|
50
|
-
--> "100"
|
|
51
|
-
```
|
|
25
|
+
[](https://asciinema.org/a/UZuFpX4a5CQ47JTQngv253EVv)
|
|
52
26
|
|
|
53
27
|
---
|
|
54
28
|
|
|
@@ -60,9 +34,11 @@ An example of a _partial function_ is the _projection_, e.g., "`.toto`",
|
|
|
60
34
|
which maps an object to its property named `toto`, or it is not defined if
|
|
61
35
|
the property doesn't exist. E.g.,
|
|
62
36
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
```text
|
|
38
|
+
1 .toto :
|
|
39
|
+
2 {"toto": 5, "titi": 10} --> 5
|
|
40
|
+
3 {"titi": 10} ... undefined // it is not a value!
|
|
41
|
+
```
|
|
66
42
|
|
|
67
43
|
> Note: The above 3 lines should be read as follows. A `k`-expression
|
|
68
44
|
> is printed in the first line (before "`:`"). The following lines
|
|
@@ -81,25 +57,30 @@ There are three ways of combining functions:
|
|
|
81
57
|
1. **composition**: `(f1 f2 ...)`, e.g. `(.toto .titi)` extracts
|
|
82
58
|
nested field.
|
|
83
59
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
60
|
+
```text
|
|
61
|
+
(.toto .titi) :
|
|
62
|
+
{"toto": {"titi": 10}} --> 10
|
|
63
|
+
{"toto": {"other": 8}} ... undefined
|
|
64
|
+
{"other": {}} ... undefined
|
|
65
|
+
```
|
|
88
66
|
|
|
89
67
|
2. **merge**: `< f1, f2,... >`, e.g., `<.toto, .titi>` extracts field
|
|
90
68
|
`toto` if present; otherwise extracts `titi`.
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
70
|
+
```text
|
|
71
|
+
< .x.y, .z.y > :
|
|
72
|
+
{"x":{"y": 5}, "z": {"y":10}} --> 5
|
|
73
|
+
{"x":{"o":{}}, "z": {"y":10}} --> 10
|
|
74
|
+
{"x":{"o":{}}, "z": {"o":{}}} ... undefined
|
|
75
|
+
```
|
|
96
76
|
|
|
97
77
|
3. **product**: `{ f1 label1, f2 label2, ...}`, e.g., `{.toto TOTO,
|
|
98
|
-
.titi TITI}` extracts two fields and builds a record out of them.
|
|
78
|
+
.titi TITI}` extracts two fields and builds a record out of them.
|
|
99
79
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
```text
|
|
81
|
+
{.toto TOTO, .titi TITI} :
|
|
82
|
+
{"toto": 5, "titi": 10, "x": 3} --> {"TOTO": 5, "TITI": 10}
|
|
83
|
+
```
|
|
103
84
|
|
|
104
85
|
---
|
|
105
86
|
|
|
@@ -132,46 +113,54 @@ supported.
|
|
|
132
113
|
A constant defines a function which ignores its argument and produces
|
|
133
114
|
the constant value. E.g.:
|
|
134
115
|
|
|
135
|
-
|
|
136
|
-
|
|
116
|
+
```text
|
|
117
|
+
{123 int, "kScript" str, true bool, null null} :
|
|
118
|
+
"any" --> {"int":123,"str":"kScript","bool":true,"null":null}
|
|
119
|
+
```
|
|
137
120
|
|
|
138
121
|
Those values, i.e., _strings_, _integers_, _booleans_, and _null_, admit the
|
|
139
|
-
projection to the
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
122
|
+
projection, via (`.`), to the canonical string representation of the value, e.g.:
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
."a string" :
|
|
126
|
+
"a string" --> {}
|
|
127
|
+
"other" ... undefined
|
|
128
|
+
11 ... undefined
|
|
129
|
+
null ... undefined
|
|
130
|
+
.2 :
|
|
131
|
+
2 --> {}
|
|
132
|
+
"2" --> {}
|
|
133
|
+
4 ... undefined
|
|
134
|
+
true ... undefined
|
|
135
|
+
|
|
136
|
+
.true :
|
|
137
|
+
true --> {}
|
|
138
|
+
"true" --> {}
|
|
139
|
+
4 ... undefined
|
|
140
|
+
"toto" ... undefined
|
|
141
|
+
|
|
142
|
+
.null :
|
|
143
|
+
null --> {}
|
|
144
|
+
"null" --> {}
|
|
145
|
+
4 ... undefined
|
|
146
|
+
false ... undefined
|
|
147
|
+
```
|
|
158
148
|
|
|
159
149
|
#### Vector product
|
|
160
150
|
|
|
161
|
-
Vector product can be seen as an abbreviation for product whose
|
|
162
|
-
names are integers starting from zero.
|
|
151
|
+
Vector product can be seen as an abbreviation for product whose all fields
|
|
152
|
+
have the same type, and the filed names are integers starting from zero.
|
|
163
153
|
E.g., `{.toto 0, .titi 1, 123 2}` can be written as
|
|
164
154
|
`[.toto, .titi, 123]`.
|
|
165
155
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
.1 :
|
|
170
|
-
["A","B","C"] --> "B"
|
|
171
|
-
["a"] ... undefined
|
|
156
|
+
```text
|
|
157
|
+
[.toto, .titi, 12] :
|
|
158
|
+
{"toto": 5, "titi": 10 } --> [5, 10, 12]
|
|
172
159
|
|
|
173
|
-
|
|
174
|
-
|
|
160
|
+
. 2 :
|
|
161
|
+
["A","B","C"] --> "C"
|
|
162
|
+
["a"] ... undefined
|
|
163
|
+
```
|
|
175
164
|
|
|
176
165
|
---
|
|
177
166
|
|
|
@@ -204,7 +193,7 @@ is not supported in _code derivation_ (explained below).
|
|
|
204
193
|
|
|
205
194
|
CONCAT:
|
|
206
195
|
["a","bc","d"] --> "abcd"
|
|
207
|
-
[
|
|
196
|
+
[] --> ""
|
|
208
197
|
|
|
209
198
|
- `toJSON` and `fromJSON` -- conversion to and from JSON strings
|
|
210
199
|
|
|
@@ -213,8 +202,6 @@ is not supported in _code derivation_ (explained below).
|
|
|
213
202
|
|
|
214
203
|
fromJSON:
|
|
215
204
|
"{\"a\":12}" --> {"a":12}
|
|
216
|
-
"2.12" --> 2.12
|
|
217
|
-
"[1,2.11,0.3e-32]" --> [1,2.11,3e-33]
|
|
218
205
|
|
|
219
206
|
- other predefined parial functions are: `DIV`, `FDIV`, `CONS`,
|
|
220
207
|
`SNOC`, `toVEC`, `toDateMsec`, `toDateStr`, and `_log!`.
|
|
@@ -223,24 +210,47 @@ is not supported in _code derivation_ (explained below).
|
|
|
223
210
|
|
|
224
211
|
### Function and code (i.e., _type_) definitions
|
|
225
212
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
213
|
+
```k-repl
|
|
214
|
+
dec = [(),-1] PLUS;
|
|
215
|
+
max = <SNOC [.car, .cdr max] <GT.0, .1>, .0> ;
|
|
216
|
+
factorial = < [(),0] GT .0 [dec factorial, ()] TIMES, 1 >;
|
|
217
|
+
6 factorial
|
|
218
|
+
--> 720
|
|
219
|
+
```
|
|
229
220
|
|
|
230
221
|
### Codes (schemas, i.e., _types_)
|
|
231
222
|
|
|
232
|
-
_Codes_
|
|
223
|
+
_Codes_ can be defined by tagged union and product. E.g.:
|
|
233
224
|
|
|
225
|
+
```k-repl
|
|
226
|
+
$ nat = < nat 1, {} 0 >;
|
|
227
|
+
$ pair = { nat x, nat y };
|
|
234
228
|
|
|
235
|
-
|
|
236
|
-
|
|
229
|
+
suc = { $ nat 1 };
|
|
230
|
+
add = $ pair <{.x.1 x, .y suc y} add, .y>;
|
|
231
|
+
```
|
|
237
232
|
|
|
238
|
-
|
|
239
|
-
|
|
233
|
+
Code definition statement starts with `$`.
|
|
234
|
+
Also, any code expression occurrig within a `k`-expression is prefixed by `$`.
|
|
240
235
|
|
|
241
236
|
Two codes are considered equal when they are isomorphic (preserving
|
|
242
237
|
union/product and field names). E.g., `$pair`, `${nat y, nat x}`, and
|
|
243
|
-
`${<nat 1, {} 0> x, nat y}` are all
|
|
238
|
+
`${<nat 1, {} 0> x, nat y}` are all equivalent and corresponds its cannonical form
|
|
239
|
+
`$C0={C1"x",C1"y"};$C1=<C2"0",C1"1">;$C2={};`.
|
|
240
|
+
|
|
241
|
+
Try in `k-repl`:
|
|
242
|
+
|
|
243
|
+
```k-repl
|
|
244
|
+
> $ nat = < nat 1, {} 0 >; \
|
|
245
|
+
$ pair = { nat x, nat y };
|
|
246
|
+
--> {}
|
|
247
|
+
> --C pair
|
|
248
|
+
$ IxLVRLECv = {BADJOX x, BADJOX y}; -- $C0={C1"x",C1"y"};$C1=<C2"0",C1"1">;$C2={};
|
|
249
|
+
$ myCode = {<nat 1, {} 0> x, nat y};
|
|
250
|
+
--> {}
|
|
251
|
+
> --C myCode
|
|
252
|
+
$ IxLVRLECv = {BADJOX x, BADJOX y}; -- $C0={C1"x",C1"y"};$C1=<C2"0",C1"1">;$C2={};
|
|
253
|
+
```
|
|
244
254
|
|
|
245
255
|
#### Basic extension codes
|
|
246
256
|
|
|
@@ -249,26 +259,33 @@ there are three predefined types: `int`, `bool`, and `string`. A
|
|
|
249
259
|
vector product code can also be defined by `[ codeExp ]`. All members
|
|
250
260
|
of the vector are the same code. E.g.,
|
|
251
261
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
```k-repl
|
|
263
|
+
$ intVector = [ int ];
|
|
264
|
+
$ boolVector = [ bool ];
|
|
265
|
+
$ tree = [ tree ];
|
|
266
|
+
```
|
|
255
267
|
|
|
256
268
|
### Code derivation and Patterns
|
|
257
269
|
|
|
258
270
|
Intuitively, a _pattern_ represents some set of contraints on
|
|
259
271
|
codes. For example, expression `.toto` is a projection from a value of
|
|
260
|
-
a product or a union with field `toto`. Therefore, expression `.toto`
|
|
272
|
+
a product or a union code with field `toto`. Therefore, expression `.toto`
|
|
261
273
|
introduces two patterns `p_i` and `p_o` (for input and output codes,
|
|
262
274
|
respectively); `p_o` imposes no constraint on code, however `p_i` is a
|
|
263
275
|
product or union code with field `toto` leading to a code fulfilling
|
|
264
|
-
`p_o`,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
276
|
+
`p_o`, which will be denoted by:
|
|
277
|
+
|
|
278
|
+
```k-repl
|
|
279
|
+
> toto = .toto;
|
|
280
|
+
--> {}
|
|
281
|
+
> --R toto
|
|
282
|
+
toto : ?(X0 toto, ...) --> ?X0
|
|
283
|
+
toto = .toto;
|
|
284
|
+
```
|
|
268
285
|
|
|
269
286
|
In a more complex expression each (occurrence of) subexpression will
|
|
270
287
|
introduce some new patterns.
|
|
271
|
-
For example, concider
|
|
288
|
+
For example, concider ` rel = <.toto, ()>; `.
|
|
272
289
|
|
|
273
290
|
< .toto , () >
|
|
274
291
|
p1 p2 p3 p4 p5 p6
|
|
@@ -278,28 +295,27 @@ and `p6` is the pattern for the output. We can deduce that patterns
|
|
|
278
295
|
(`p1`, `p2`, `p4`) defines the same code, as well as (`p6`, `p5`, `p3`),
|
|
279
296
|
because union combines partial functions with the same input and output codes.
|
|
280
297
|
Identity, `()`, implies that (`p4`, `p5`) define the
|
|
281
|
-
same code.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
Since the product code pattern (i.e., latter case) doesn't admmit any
|
|
291
|
-
(finite) value, we conclude that the code `c` is a union (i.e.,
|
|
292
|
-
former case).
|
|
298
|
+
same code. In `k-repl`:
|
|
299
|
+
|
|
300
|
+
```k-repl
|
|
301
|
+
> rel = < .toto, () >;
|
|
302
|
+
--> {}
|
|
303
|
+
> --R rel
|
|
304
|
+
rel : ?(X0 toto, ...)=X0 --> ?X0
|
|
305
|
+
rel = <.toto, ()>;
|
|
306
|
+
```
|
|
293
307
|
|
|
294
308
|
For a given `kScript`, code derivation (as any static analysis) can
|
|
295
309
|
fail, indicating that the script is invalid. In some other cases the
|
|
296
310
|
code derivation can succeed even to the point of reducig every pattern
|
|
297
311
|
to a single code making the program fully annotated by codes.
|
|
298
312
|
|
|
299
|
-
The language `k` supports _type patterns_, which is used for
|
|
313
|
+
The language `k` supports _type patterns_, which is used for code
|
|
314
|
+
derivation, however the patterns are not concidered in the
|
|
315
|
+
evaluation of the program.
|
|
300
316
|
|
|
301
|
-
```k
|
|
302
|
-
|
|
317
|
+
```k-repl
|
|
318
|
+
treePattern = ?<(...) leaf, {T left, T right} tree> = T;
|
|
303
319
|
```
|
|
304
320
|
|
|
305
321
|
---
|
|
@@ -307,13 +323,13 @@ The language `k` supports _type patterns_, which is used for type inference, how
|
|
|
307
323
|
### List comprehension
|
|
308
324
|
|
|
309
325
|
A vector can be "open" by PIPE (`|`) operator so the following partial function is applied to
|
|
310
|
-
each element of the vector
|
|
326
|
+
each element of the vector, yielding another open value. An open value can be "closed",
|
|
311
327
|
i.e., turn into a regular vector using `CARET` (`^`) operator. E.g.:
|
|
312
328
|
|
|
313
329
|
```k
|
|
314
330
|
| .x ^ :
|
|
315
|
-
[{x:12}, {x:8
|
|
316
|
-
[
|
|
331
|
+
[{x:12}, {x:8}, {y:98}] --> [12,8]
|
|
332
|
+
["a","x","b","x"] --> [{},{}]
|
|
317
333
|
```
|
|
318
334
|
|
|
319
335
|
The PIPE operator can be used for defining the Cartesian product:
|
|
@@ -354,8 +370,8 @@ times value `x` appears in the list. (see `Examples/list-comprehension.k` for a
|
|
|
354
370
|
1. projection:
|
|
355
371
|
|
|
356
372
|
.x
|
|
357
|
-
."field name"
|
|
358
|
-
.4
|
|
373
|
+
. "field name"
|
|
374
|
+
(. 4)
|
|
359
375
|
|
|
360
376
|
The function is defined if its argument "has" the field.
|
|
361
377
|
|
|
@@ -398,11 +414,11 @@ times value `x` appears in the list. (see `Examples/list-comprehension.k` for a
|
|
|
398
414
|
Another example could be finding the biggest (max) value in a vector:
|
|
399
415
|
|
|
400
416
|
max = <
|
|
401
|
-
SNOC #
|
|
402
|
-
[.car, .cdr max] #
|
|
403
|
-
<GT .0, .1> #
|
|
417
|
+
SNOC # [x0, x1, x2, ...] --> {x0 car, [x1, x2, ...] cdr}
|
|
418
|
+
[.car, .cdr max] # {car:x0, cdr:[x1, x2, ...]} --> [x0, max(x1,x2,...)], recursive call
|
|
419
|
+
<GT .0, .1> # if x0 > max(x1,x2,...) then x0 else max(x1,x2,...)
|
|
404
420
|
, # when SNOC is not defined, i.e., if the input vector has one element:
|
|
405
|
-
.0 #
|
|
421
|
+
.0 # [x0] --> x0
|
|
406
422
|
>;
|
|
407
423
|
max
|
|
408
424
|
|
|
@@ -488,16 +504,16 @@ For example:
|
|
|
488
504
|
|
|
489
505
|
> k -k test.k
|
|
490
506
|
|
|
491
|
-
If we want to read `json` objects from a file, e.g., `my-objects.
|
|
507
|
+
If we want to read `json` objects from a file, e.g., `my-objects.jsonl`, we do
|
|
492
508
|
|
|
493
|
-
> k -k test.k my-objects.
|
|
509
|
+
> k -k test.k my-objects.jsonl
|
|
494
510
|
{"x&y":"x=432 & y=123"}
|
|
495
511
|
{"x&y":"only x=987"}
|
|
496
512
|
{"x&y":"no x nor y"}
|
|
497
513
|
|
|
498
514
|
where:
|
|
499
515
|
|
|
500
|
-
> cat my-objects.
|
|
516
|
+
> cat my-objects.jsonl
|
|
501
517
|
####################################################
|
|
502
518
|
# empty lines and lines starting with # are ignored
|
|
503
519
|
{"y": 123, "x": 432,"others": "..."}
|
|
@@ -509,40 +525,28 @@ For example:
|
|
|
509
525
|
|
|
510
526
|
### Short comparaison with `jq` tutorial examples: <https://stedolan.github.io/jq/tutorial/>
|
|
511
527
|
|
|
512
|
-
|
|
513
|
-
curl 'https://api.github.com/repositories/5101141/commits?per_page=5' | jq '.'
|
|
514
|
-
curl 'https://api.github.com/repositories/5101141/commits?per_page=5' | k '()' -1
|
|
515
|
-
2.
|
|
516
|
-
curl 'https://api.github.com/repositories/5101141/commits?per_page=5' | jq '.[0]'
|
|
517
|
-
curl 'https://api.github.com/repositories/5101141/commits?per_page=5' | k '.0' -1
|
|
518
|
-
3.
|
|
519
|
-
jq '.[0] | {message: .commit.message, name: .commit.committer.name}'
|
|
520
|
-
k '.0 {.commit.message message, .commit.committer.name name}' -1
|
|
521
|
-
4. note: `k`-expression defines a partial function yielding a single json object, i.e., as far as `k` is concerned,
|
|
522
|
-
examples 4 and 5 of the `jq` tutorial are equivalent.
|
|
523
|
-
5.
|
|
524
|
-
jq '[.[] | {message: .commit.message, name: .commit.committer.name}]'
|
|
525
|
-
k '| .commit {.message message, .committer.name name} ^' -1
|
|
526
|
-
6.
|
|
527
|
-
jq '[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'
|
|
528
|
-
k '| {.commit.message message, .commit.committer.name name, .parents | .html_url ^ parents} ^' -1
|
|
528
|
+
[](https://asciinema.org/a/ItH7nkc5CwFOopH8Fsr23oCWj)
|
|
529
529
|
|
|
530
530
|
---
|
|
531
531
|
|
|
532
532
|
## k-REPL (Read-Evaluate-Print Loop)
|
|
533
533
|
|
|
534
|
-
Also there is a REPL, `k-repl` (`./node_modules/.bin/k-repl`),
|
|
535
|
-
shell for the language.
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
534
|
+
Also there is a REPL, `k-repl` (`./node_modules/.bin/k-repl`),
|
|
535
|
+
which acts like a toy shell for the language.
|
|
536
|
+
|
|
537
|
+
```k-repl
|
|
538
|
+
$ k-repl
|
|
539
|
+
Very! experimental repl shell for 'k-language'...
|
|
540
|
+
--c print aliased codes
|
|
541
|
+
--C code print 'code' definition
|
|
542
|
+
--r print relations
|
|
543
|
+
--R rel print 'rel' definition with type patterns
|
|
544
|
+
--p (--pp) pretty-print last value
|
|
545
|
+
--s (--g) reg store (get) the current value in (from) register 'reg'
|
|
546
|
+
--regs print register names
|
|
547
|
+
--l file.k load 'file.k'
|
|
548
|
+
>
|
|
549
|
+
```
|
|
546
550
|
|
|
547
551
|
---
|
|
548
552
|
|