Update demos and adds <|
This commit is contained in:
22
demos/interactionTrees/state.tri
Normal file
22
demos/interactionTrees/state.tri
Normal file
@@ -0,0 +1,22 @@
|
||||
!import "../../lib/base.tri" !Local
|
||||
!import "../../lib/list.tri" !Local
|
||||
!import "../../lib/io.tri" !Local
|
||||
|
||||
-- Mutable state via get and put.
|
||||
-- get reads the current state.
|
||||
-- put replaces the state.
|
||||
--
|
||||
-- The CLI starts with an empty (Leaf) state. This demo puts
|
||||
-- readable strings and prints them back out.
|
||||
|
||||
main = io <|
|
||||
bind (put "idle") (_ :
|
||||
bind get (s1 :
|
||||
bind (putStrLn (append "state: " s1)) (_ :
|
||||
bind (put "running") (_ :
|
||||
bind get (s2 :
|
||||
bind (putStrLn (append "state: " s2)) (_ :
|
||||
bind (put "done") (_ :
|
||||
bind get (s3 :
|
||||
bind (putStrLn (append "state: " s3)) (_ :
|
||||
pure t)))))))))
|
||||
Reference in New Issue
Block a user