27 lines
813 B
Plaintext
27 lines
813 B
Plaintext
-- Manual test for async getLine
|
|
--
|
|
-- Run with:
|
|
-- nix run .# -- eval -f demos/async-getline-test.tri --io
|
|
--
|
|
-- Expected behaviour:
|
|
-- 1. You immediately see:
|
|
-- Please enter your first name:
|
|
-- (this printed before you typed anything)
|
|
-- (this second line also printed before you typed anything)
|
|
-- 2. You type your name and press Enter.
|
|
-- 3. You see:
|
|
-- Hello, <name>!
|
|
|
|
!import "prelude" !Local
|
|
!import "io" !Local
|
|
|
|
main = io <|
|
|
bind (fork getLine) (h :
|
|
bind (putStr "Please enter your first name: ") (_ :
|
|
bind (putStr "\n(this printed before you typed anything)\n") (_ :
|
|
bind (putStr "\n(this second line also printed before you typed anything)\n") (_ :
|
|
bind (await h) (name :
|
|
bind (putStr "Hello, ") (_ :
|
|
bind (putStr name) (_ :
|
|
putStr "!\n")))))))
|