aboutsummaryrefslogtreecommitdiff
path: root/examples/greeting.ts
blob: f285313bd1499dde7a7b851a450532a3f1e6988e (plain) (blame)
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
import { Bind, Do, Kind1 } from '../stdlib/effect'
import { WriteFile } from '../stdlib/fs'
import { PutString, ReadLine, PutStringLn } from '../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'>
]

interface HandleResponseK extends Kind1<string> {
  return: Do<
    [
      PutStringLn<`Interesting that you believe "${this['input']}" is your purpose. Hmmmm...`>,
      PutStringLn<'Judging harshly...'>,
      PutStringLn<'Saving response...'>,
      WriteFile<'./response.txt', this['input']>
    ]
  >
}