Skip to content

Commit

Permalink
Add comments to example code
Browse files Browse the repository at this point in the history
  • Loading branch information
ENvironmentSet committed Aug 11, 2023
1 parent 543cbe6 commit 3461a88
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
import { Spec, createEffect, Effectful } from 'hyogwa';
import { unsafeRunSync } from 'hyogwa/runners';

// Definition of IO Effect

interface IO extends Spec<'IO'> {
read(): string
write(text: string): void
}
const IO = createEffect<IO>('IO')

// Definition of main function with IO effect

function* main(): Effectful<IO, void> {
const name = yield* IO.read()

yield* IO.write(`Welcome to hyogwa, ${name}!`)
}

// Running main function

unsafeRunSync(main(), {
IO: {
read({ resume }) {
Expand Down

0 comments on commit 3461a88

Please sign in to comment.