1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# TS Types lang
A runtime for typescript's **type system** that turns it into a **general purpose**, **purely functional** programming language with effects!
## Documentation
- [stdlib reference](./docs/modules.md)
- [examples](./examples/)
## Implemented effects
* read/write file
* simple stdio interactions
* error handling
* test runner
* mutable references
* js ffi
* get cli args, env vars
## Example
Take a look at the [./examples](./examples/) directory for more examples on how to write a program in typescript types
```typescript
import { Bind, Do, Kind1 } from 'ts-types-lang/stdlib/effect'
import { WriteFile } from 'ts-types-lang/stdlib/fs'
import { PutString, ReadLine, PutStringLn } from 'ts-types-lang/stdlib/stdio'
export type main = [
PutStringLn<'Greetotron 6000 initializing...'>,
PutStringLn<''>,
PutString<'Your name? '>,
Bind<ReadLine, <name extends string>() =>
PutStringLn<`Hello, ${name}`>>,
PutString<'Your purpose in life? '>,
Bind<ReadLine, HandleResponseK>,
PutStringLn<'Bye bye'>,
]
// :: string -> Effect ()
interface HandleResponseK extends Kind1<string, Effect> {
return: Do<[
PutStringLn<`Interesting that you believe "${this['input']}" is your purpose. Hmmmm...`>,
PutStringLn<'Judging harshly...'>,
PutStringLn<'Saving response...'>,
WriteFile<'./response.txt', this['input']>,
]>
}
```
## Run a types-lang module
Install it -
```bash
npm i --save ts-types-lang
# OR
yarn add ts-types-lang
```
Or just run it -
```bash
npx tsr run ./examples/guess-number.ts
# OR
yarn exec tsr run ./examples/guess-number.ts
```
## FAQ
#### Why?
Why not?
#### How?
Why?
#### What?
What?
#### Should I use this?
No
|