Update demos and adds <|
This commit is contained in:
20
demos/interactionTrees/environment.tri
Normal file
20
demos/interactionTrees/environment.tri
Normal file
@@ -0,0 +1,20 @@
|
||||
!import "../../lib/base.tri" !Local
|
||||
!import "../../lib/list.tri" !Local
|
||||
!import "../../lib/io.tri" !Local
|
||||
|
||||
-- Environment effects: ask and local.
|
||||
-- ask reads the current environment value.
|
||||
-- local f action runs action with the env transformed by f.
|
||||
--
|
||||
-- The CLI starts with an empty (Leaf) environment. This demo uses
|
||||
-- local to inject a real string so that ask returns something readable.
|
||||
|
||||
main = io <|
|
||||
(bind
|
||||
local (_ : "sandbox")
|
||||
(bind ask (env :
|
||||
bind (putStrLn (append "working in env: " env)) (_ :
|
||||
pure "inside-done"))))
|
||||
(outside :
|
||||
bind (putStrLn (append "local returned: " outside)) (_ :
|
||||
pure t))
|
||||
Reference in New Issue
Block a user