getLineAsync.tri (813B)
1 -- Manual test for async getLine 2 -- 3 -- Run with: 4 -- nix run .# -- eval -f demos/async-getline-test.tri --io 5 -- 6 -- Expected behaviour: 7 -- 1. You immediately see: 8 -- Please enter your first name: 9 -- (this printed before you typed anything) 10 -- (this second line also printed before you typed anything) 11 -- 2. You type your name and press Enter. 12 -- 3. You see: 13 -- Hello, <name>! 14 15 !import "prelude" !Local 16 !import "io" !Local 17 18 main = io <| 19 bind (fork getLine) (h : 20 bind (putStr "Please enter your first name: ") (_ : 21 bind (putStr "\n(this printed before you typed anything)\n") (_ : 22 bind (putStr "\n(this second line also printed before you typed anything)\n") (_ : 23 bind (await h) (name : 24 bind (putStr "Hello, ") (_ : 25 bind (putStr name) (_ : 26 putStr "!\n")))))))