environment.tri (587B)
1 !import "prelude" !Local 2 !import "io" !Local 3 4 -- Environment effects: ask and local. 5 -- ask reads the current environment value. 6 -- local f action runs action with the env transformed by f. 7 -- 8 -- The CLI starts with an empty (Leaf) environment. This demo uses 9 -- local to inject a real string so that ask returns something readable. 10 11 main = io <| 12 (bind 13 local (_ : "sandbox") 14 (bind ask (env : 15 bind (putStrLn (append "working in env: " env)) (_ : 16 pure "inside-done")))) 17 (outside : 18 bind (putStrLn (append "local returned: " outside)) (_ : 19 pure t))