tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

safeRead.tri (406B)


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