tricu

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

shout.tri (531B)


      1 !import "prelude" !Local
      2 !import "io"      !Local
      3 
      4 -- Transform an IO result.
      5 --   mapIO applies a pure function to the value produced by an action.
      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 "missing")
     13         (contents rest : pure contents)
     14         result))
     15 
     16 shout = (path :
     17   mapIO (safeRead path)
     18     (text : append text "!!!"))
     19 
     20 main = io (bind 
     21     (shout "demos/interactionTrees/greet.tri")
     22     (text : putStrLn text))