From 853112fcb4cfd44d39f0232d2e9b465636e3cc7d Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 15 Jan 2023 00:29:18 +0530 Subject: chore: better example --- examples/greeting.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'examples') 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 { - 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() => PutStringLn<`Hello, ${name}`>>, - PutStringLn<'----------------'>, PutString<'Your purpose in life? '>, - Bind, + Bind, - PutStringLn<'----------------'> + PutStringLn<'Bye bye'> ] + +interface HandleResponseK extends Kind1 { + return: Do< + [ + PutStringLn<`Interesting that you believe "${this['input']}" is your purpose. Hmmmm...`>, + PutStringLn<'Judging harshly...'>, + PutStringLn<'Saving response...'>, + WriteFile<'./response.txt', this['input']> + ] + > +} -- cgit v1.3.1