safeRead.tri (397B)
1 !import prelude * 2 !import io * 3 !export * 4 5 -- readFile returns a Result. matchResult branches on ok / err. 6 -- Run with --allow-read PATH or --unsafe-io. 7 8 safeRead = (path : 9 bind (readFile path) 10 (result : 11 matchResult 12 (err rest : pure "ERROR: Unable to read file") 13 (contents rest : pure contents) 14 result)) 15 16 main = io (safeRead "demos/interactionTrees/greet.tri")