diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-15 00:29:18 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-15 00:29:18 +0530 |
| commit | 853112fcb4cfd44d39f0232d2e9b465636e3cc7d (patch) | |
| tree | 1def8f2f6599af4e9a6a56867b90cdc9df4bc754 /examples | |
| parent | d5c3af89ab8076bcf4107859c1ba6b47a7815142 (diff) | |
| download | ts-types-lang-853112fcb4cfd44d39f0232d2e9b465636e3cc7d.tar.gz ts-types-lang-853112fcb4cfd44d39f0232d2e9b465636e3cc7d.zip | |
chore: better example
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/greeting.ts | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/examples/greeting.ts b/examples/greeting.ts index 72edde2..f285313 100644 --- a/examples/greeting.ts +++ b/examples/greeting.ts @@ -1,20 +1,27 @@ -import { Bind, Kind1 } from '../stdlib/effect' +import { Bind, Do, Kind1 } from '../stdlib/effect' +import { WriteFile } from '../stdlib/fs' import { PutString, ReadLine, PutStringLn } from '../stdlib/stdio' -interface ResponseK extends Kind1<string> { - return: PutStringLn<`Interesting that you believe "${this['input']}" is your purpose. Hmmmm...`> -} - export type main = [ PutStringLn<'Greetotron 6000 initializing...'>, + PutStringLn<''>, - PutStringLn<'----------------'>, PutString<'Your name? '>, Bind<ReadLine, <name extends string>() => PutStringLn<`Hello, ${name}`>>, - PutStringLn<'----------------'>, PutString<'Your purpose in life? '>, - Bind<ReadLine, ResponseK>, + Bind<ReadLine, HandleResponseK>, - PutStringLn<'----------------'> + 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']> + ] + > +} |
