Created
August 6, 2020 04:51
-
-
Save bukzor/ad7fb90dc922d445f4414ca1f5c35fe7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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