diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-08 23:07:41 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-08 23:07:41 +0530 |
| commit | 580ef150778326262d04018460f672bda53d5696 (patch) | |
| tree | 53b93a2e381e6c15ed4e959f766fc88afc234a0f /examples | |
| parent | a41d70afe7692e4ef344bc3c599115009f2dad15 (diff) | |
| download | ts-types-lang-580ef150778326262d04018460f672bda53d5696.tar.gz ts-types-lang-580ef150778326262d04018460f672bda53d5696.zip | |
chore: adds prettier
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/custom-effect.ts | 15 | ||||
| -rw-r--r-- | examples/ffi.ts | 23 | ||||
| -rw-r--r-- | examples/file.ts | 6 | ||||
| -rw-r--r-- | examples/greeting.ts | 13 | ||||
| -rw-r--r-- | examples/guess-number.ts | 50 |
5 files changed, 57 insertions, 50 deletions
diff --git a/examples/custom-effect.ts b/examples/custom-effect.ts index 5fbffed..3dbe395 100644 --- a/examples/custom-effect.ts +++ b/examples/custom-effect.ts @@ -1,15 +1,18 @@ import { Bind, DefineEffect, Effect, Kind1, Print } from '../stdlib' -interface Mathemagic<_A, _B> extends Effect { } +interface Mathemagic<_A, _B> extends Effect {} interface PrintK extends Kind1 { return: Print<this['input']> } export type main = [ - DefineEffect<"Mathemagic", `(a, b) => { - console.log(typeToString(a)) - return { result: 5 * b.getLiteralValue() } - }`>, - Bind<Mathemagic<"a", 69>, PrintK>, + DefineEffect< + 'Mathemagic', + `(a, b) => { + console.log(typeToString(a)) + return { result: 5 * b.getLiteralValue() } + }` + >, + Bind<Mathemagic<'a', 69>, PrintK> ] diff --git a/examples/ffi.ts b/examples/ffi.ts index 484e84d..0840ff6 100644 --- a/examples/ffi.ts +++ b/examples/ffi.ts @@ -1,19 +1,22 @@ -import { Bind, Debug, DefineEffect, Effect, JsExpr, Kind1 } from "../stdlib" +import { Bind, Debug, DefineEffect, Effect, JsExpr, Kind1 } from '../stdlib' -interface PrintK<Label extends string = ""> extends Kind1 { +interface PrintK<Label extends string = ''> extends Kind1 { return: Debug<Label, this['input']> } type Square<N extends number> = JsExpr<`${N} ** 2`> -interface Mathemagic<_A, _B extends number> extends Effect { } +interface Mathemagic<_A, _B extends number> extends Effect {} export type main = [ - Bind<JsExpr<"{ boobaa: [5 * 3, 5 * 2] }">, PrintK<'|'>>, - Bind<Square<69>, PrintK<"69^2 =">>, - DefineEffect<"Mathemagic", `(a, b) => { - console.log(typeToString(a)) - return { result: 5 * b.getLiteralValue() } - }`>, - Bind<Mathemagic<"a", 69>, PrintK<'69 * 5 ='>>, + Bind<JsExpr<'{ boobaa: [5 * 3, 5 * 2] }'>, PrintK<'|'>>, + Bind<Square<69>, PrintK<'69^2 ='>>, + DefineEffect< + 'Mathemagic', + `(a, b) => { + console.log(typeToString(a)) + return { result: 5 * b.getLiteralValue() } + }` + >, + Bind<Mathemagic<'a', 69>, PrintK<'69 * 5 ='>> ] diff --git a/examples/file.ts b/examples/file.ts index 279a51b..287f108 100644 --- a/examples/file.ts +++ b/examples/file.ts @@ -1,9 +1,7 @@ -import { Bind, Kind1, ReadFile, WriteFile, PutStringLn } from '../stdlib' +import { Bind, Kind1, ReadFile, PutStringLn } from '../stdlib' interface PrintK extends Kind1<string> { return: PutStringLn<this['input']> } -export type main = [ - Bind<ReadFile<"./default.nix">, PrintK>, -] +export type main = Bind<ReadFile<'./default.nix'>, PrintK> diff --git a/examples/greeting.ts b/examples/greeting.ts index ac59151..20ed4fe 100644 --- a/examples/greeting.ts +++ b/examples/greeting.ts @@ -1,14 +1,11 @@ -import { PutString, Bind, Kind1, ReadLine, Seq } from '../stdlib' +import { PutString, Bind, Kind1, ReadLine, Seq, PutStringLn } from '../stdlib' interface GreetK extends Kind1<string> { - return: Seq<[ - PutString<"Hello, ">, - PutString<`${this['input']}\n`> - ]>, + return: Seq<[PutString<'Hello, '>, PutString<`${this['input']}\n`>]> } export type main = [ - PutString<"Your name? ">, - Bind<ReadLine, GreetK>, + PutStringLn<'Greetotron 6000 initializing...'>, + PutString<'Your name? '>, + Bind<ReadLine, GreetK> ] - diff --git a/examples/guess-number.ts b/examples/guess-number.ts index a20c993..d08c616 100644 --- a/examples/guess-number.ts +++ b/examples/guess-number.ts @@ -1,33 +1,39 @@ -import { Print, PutString, Bind, Kind1, JsExpr, ReadLine, Do, PutStringLn } from '../stdlib' +import { + Print, + PutString, + Bind, + Kind1, + JsExpr, + ReadLine, + Do, + PutStringLn, +} from '../stdlib' export type main = [ - PutStringLn<"Guess a number between 0 & 9. You have 5 guesses">, - Bind< - JsExpr<"Math.floor(Math.random() * 10)">, - StartGuessing - > + PutStringLn<'Guess a number between 0 & 9. You have 5 guesses'>, + Bind<JsExpr<'Math.floor(Math.random() * 10)'>, StartGuessing> ] -interface AskForGuess<N extends number, Attempts extends 0[]> extends Kind1<string> { +interface AskForGuess<N extends number, Attempts extends 0[]> + extends Kind1<string> { return: `${this['input']}` extends `${N}` - ? PutStringLn<"Yay! You got it right!"> - : Do<[ - Print<`Wrong guess. Total attempts: ${ - [...Attempts, 0] extends infer Ls extends 0[] ? Ls['length'] : 0 - }/5`>, - (StartGuessing<[...Attempts, 0]> & { input: N })['return'], - ]> + ? PutStringLn<'Yay! You got it right!'> + : Do< + [ + PutString<'Wrong guess. Total attempts'>, + Print<`${[...Attempts, 0] extends infer Ls extends 0[] + ? Ls['length'] + : 0}/5`>, + (StartGuessing<[...Attempts, 0]> & { input: N })['return'] + ] + > } interface StartGuessing<Attempts extends 0[] = []> extends Kind1<number> { return: Attempts['length'] extends 5 - ? PutStringLn<"Max attempts exceeded. Game over!"> + ? PutStringLn<'Max attempts exceeded. Game over!'> : Bind< - Do<[ - PutString<"Your guess? ">, - ReadLine - ]>, - AskForGuess<this['input'], Attempts> - > + Do<[PutString<'Your guess? '>, ReadLine]>, + AskForGuess<this['input'], Attempts> + > } - |
