Skip to content

Instantly share code, notes, and snippets.

@bukzor
Created August 6, 2020 04:51
Show Gist options
  • Select an option

  • Save bukzor/ad7fb90dc922d445f4414ca1f5c35fe7 to your computer and use it in GitHub Desktop.

Select an option

Save bukzor/ad7fb90dc922d445f4414ca1f5c35fe7 to your computer and use it in GitHub Desktop.
$ cat head2.fm
head2.IO.readline(_: Unit): IO(String)
use line = IO.ask<String>("get_line", "")
IO.end<String>(line)
head2: IO(Unit)
get bind pure = IO.monad
let io0 = pure<>(Unit.new)
let io1 = bind<,>(io0, head2.IO.readline)
let io2 = bind<,>(io1, IO.print)
let io3 = bind<,>(io2, head2.IO.readline)
bind<,>(io3, IO.print)
$ fm head2.fm
Type-checking:
head2.IO.readline: (_: Unit) -> IO(String)
head2: IO(Unit)
$ seq 3 | fmio head2
1
1
2
2
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment