2beaabce9c2d9c6ee299d8ccbd3be62499782b9c10b6439c1027c8da7452a166.tri (522B)
1 !import prelude * 2 !import io * 3 !export * 4 5 -- Transform an IO result. 6 -- mapIO applies a pure function to the value produced by an action. 7 -- Run with --allow-read PATH or --unsafe-io. 8 9 safeRead = (path : 10 bind (readFile path) 11 (result : 12 matchResult 13 (err rest : pure "missing") 14 (contents rest : pure contents) 15 result)) 16 17 shout = (path : 18 mapIO (safeRead path) 19 (text : append text "!!!")) 20 21 main = io (bind 22 (shout "demos/interactionTrees/greet.tri") 23 (text : putStrLn text))