diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-06 19:46:10 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-06 19:46:10 +0530 |
| commit | d0baefe81d90d44f61322716e20850a7f6f5eaa5 (patch) | |
| tree | fa46e265f7e8fd7e4afa5d36eb00233ffcace6cc /src/index.ts | |
| parent | e319818b8cc27450237f4b6b96022458ae478ab2 (diff) | |
| download | ts-types-lang-d0baefe81d90d44f61322716e20850a7f6f5eaa5.tar.gz ts-types-lang-d0baefe81d90d44f61322716e20850a7f6f5eaa5.zip | |
feat: adds seq and refactors runtime
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/index.ts b/src/index.ts index 7ee4461..df2643a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,17 +1,38 @@ -import { Program, Print, PutString, Bind, Debug, Kind1, GetEnv, JsExpr, ReadFile, GetArgs, ReadLine } from './stdlib' +import { Program, Print, PutString, Bind, Debug, Kind1, GetEnv, JsExpr, ReadFile, GetArgs, ReadLine, Seq } from './stdlib' interface PrintK<Label extends string = ""> extends Kind1<unknown> { return: Debug<Label, this['input']> } +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']>> +} + export type main = Program<[ Bind<GetArgs, PrintK>, + PutString<"1,2,3? ">, [1, 2, 3] extends infer Res ? Print<Res> : never, Bind<GetEnv<"NODE_ENV">, PrintK>, Bind<JsExpr<"{ boobaa: [5 * 3, 5 * 2] }">, PrintK>, - // ChainIO<ReadLine, WithInputK>, Bind<ReadFile<"./default.nix">, PrintK>, + PutString<"Your name? ">, Bind<ReadLine, PrintK<"Hello,">>, + + Bind< + JsExpr<"Math.floor(Math.random() * 10)">, + StartGuessing + >, + + Print<"Before times">, + Seq<[ + Print<"Hey">, + Print<"Wow">, + Bind<JsExpr<"200 * 2">, PrintK<"200 * 2 =">>, + ]>, ]> |
