From 580ef150778326262d04018460f672bda53d5696 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 8 Jan 2023 23:07:41 +0530 Subject: chore: adds prettier --- examples/guess-number.ts | 50 +++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'examples/guess-number.ts') 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, StartGuessing> ] -interface AskForGuess extends Kind1 { +interface AskForGuess + extends Kind1 { 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 extends Kind1 { return: Attempts['length'] extends 5 - ? PutStringLn<"Max attempts exceeded. Game over!"> + ? PutStringLn<'Max attempts exceeded. Game over!'> : Bind< - Do<[ - PutString<"Your guess? ">, - ReadLine - ]>, - AskForGuess - > + Do<[PutString<'Your guess? '>, ReadLine]>, + AskForGuess + > } - -- cgit v1.3.1