tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

7eaf0dbf9f3ed9b6e1098c1ee0d5953668d835070976596b8fc20e40c7d859d9.tri (804B)


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