tricu

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

aa0d8294256048c5caaa9e079a79ad729d0d77b182fa93d86e390bae008189c0.tri (550B)


      1 !import prelude *
      2 !import io *
      3 !export *
      4 
      5 -- Mutable state via get and put.
      6 --   get reads the current state.
      7 --   put replaces the state.
      8 --
      9 --   The CLI starts with an empty (Leaf) state.  This demo puts
     10 --   readable strings and prints them back out.
     11 
     12 main = io <|
     13   bind (put "idle") (_ :
     14   bind get (s1 :
     15   bind (putStrLn (append "state: " s1)) (_ :
     16   bind (put "running") (_ :
     17   bind get (s2 :
     18   bind (putStrLn (append "state: " s2)) (_ :
     19   bind (put "done") (_ :
     20   bind get (s3 :
     21   bind (putStrLn (append "state: " s3)) (_ :
     22   pure t)))))))))