@ojoxux/typecow 0.1.0 → 0.1.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/README.md +28 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
# typecow
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://github.com/Ojoxux/typecow/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
A type-level interpreter for the esoteric programming language
|
|
6
|
+
[COW](https://bigzaphod.github.io/COW/) in TypeScript
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
# npm
|
|
12
|
+
npm i --save @ojoxux/typecow
|
|
13
|
+
# yarn
|
|
14
|
+
yarn add @ojoxux/typecow
|
|
15
|
+
# pnpm
|
|
16
|
+
pnpm add @ojoxux/typecow
|
|
17
|
+
```
|
|
5
18
|
|
|
6
19
|
The program is evaluated by the TypeScript compiler. The package contains no
|
|
7
20
|
runtime interpreter.
|
|
8
21
|
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
[Playground](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3nAwhA7nAXzgDMoIQ4AiAAQgCsIAPAV0YHolUBjPSgbgBQAzmgAKZAOZQAhhQC8VCOTgBZCAHk469Sv7DkaAJIA7MM3gLKAFgCMAHWN6RW82YvY8AHnEQpsgDRwJm4AfHxwbGxUVgBMDpQCQA)
|
|
25
|
+
|
|
9
26
|
```ts
|
|
10
27
|
import type { Cow } from "@ojoxux/typecow";
|
|
11
28
|
|
|
@@ -33,41 +50,8 @@ All twelve COW commands are implemented:
|
|
|
33
50
|
| `OOM` | Write the current cell as a decimal integer |
|
|
34
51
|
| `oom` | Read a decimal integer |
|
|
35
52
|
|
|
36
|
-
Text that does not form a command is ignored.
|
|
37
|
-
|
|
38
|
-
## Input and output
|
|
39
|
-
|
|
40
|
-
`Moo` consumes one ASCII character when the current cell is zero. Otherwise it
|
|
41
|
-
appends the ASCII character represented by the cell to the output.
|
|
42
|
-
|
|
43
|
-
`oom` consumes a signed decimal integer through the next newline. `OOM` appends
|
|
44
|
-
the decimal value followed by a newline.
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
type Echo = Cow<"Moo Moo", "A">; // "A"
|
|
48
|
-
type AddOne = Cow<"oom MoO OOM", "-2\n">; // "-1\n"
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Character I/O supports 7-bit ASCII. Integer cells are represented as signed
|
|
52
|
-
unary tuples, so their practical range is limited by the TypeScript compiler's
|
|
53
|
-
type-instantiation budget. This representation keeps increment, decrement,
|
|
54
|
-
zero checks, dynamic dispatch, and decimal output predictable.
|
|
55
|
-
|
|
56
|
-
Invalid programs and inputs produce a `CowError<...>` type.
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
import type { Cow, CowError } from "@ojoxux/typecow";
|
|
60
|
-
|
|
61
|
-
type Error = Cow<"mOo">; // CowError<"memory-underflow">
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Development
|
|
65
|
-
|
|
66
|
-
```sh
|
|
67
|
-
npm install
|
|
68
|
-
npm test
|
|
69
|
-
npm run build
|
|
70
|
-
```
|
|
53
|
+
Text that does not form a command is ignored. Invalid programs and inputs
|
|
54
|
+
produce a `CowError<...>` type.
|
|
71
55
|
|
|
72
56
|
The recursive evaluator uses the same logarithmic recursion-flattening idea as
|
|
73
57
|
[@susisu/typefuck](https://github.com/susisu/typefuck), which inspired this
|
|
@@ -75,5 +59,10 @@ project.
|
|
|
75
59
|
|
|
76
60
|
## License
|
|
77
61
|
|
|
78
|
-
MIT
|
|
79
|
-
|
|
62
|
+
[MIT License](http://opensource.org/licenses/mit-license.php). See
|
|
63
|
+
[THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md) for third-party copyright
|
|
64
|
+
and license notices.
|
|
65
|
+
|
|
66
|
+
## Author
|
|
67
|
+
|
|
68
|
+
Jou Okuyama ([GitHub](https://github.com/Ojoxux))
|