diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-06 20:40:29 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-06 20:43:49 +0530 |
| commit | cda0419722b022ed0a8f3c4fd3122230b19a0c64 (patch) | |
| tree | 6d63849e950cc4c0257a2368560eb1bafefbd9d4 /examples/guess-number.ts | |
| parent | a56f093bf08780ab7ed7ef196f031c193a522922 (diff) | |
| download | ts-types-lang-cda0419722b022ed0a8f3c4fd3122230b19a0c64.tar.gz ts-types-lang-cda0419722b022ed0a8f3c4fd3122230b19a0c64.zip | |
feat: adds examples for everything
Diffstat (limited to '')
| -rw-r--r-- | examples/guess-number.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/guess-number.ts b/examples/guess-number.ts new file mode 100644 index 0000000..aca3915 --- /dev/null +++ b/examples/guess-number.ts @@ -0,0 +1,15 @@ +import { Print, PutString, Bind, Kind1, JsExpr, ReadLine, Seq } from '../src/stdlib' + +export type main = Bind< + JsExpr<"Math.floor(Math.random() * 10)">, + StartGuessing +> + +interface AskForGuess<N extends number> extends Kind1<string> { + return: this['input'] extends `${N}` ? Print<"Yaya"> : Print<"naaah"> +} + +interface StartGuessing extends Kind1<number> { + return: Bind<Seq<[PutString<"Your guess? ">, ReadLine]>, AskForGuess<this['input']>> +} + |
