tricu

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

writeThenRead.tri (507B)


      1 !import "prelude" !Local
      2 !import "io"      !Local
      3 
      4 -- Write a file, then read it back.
      5 --   thenIO discards the writeFile Result and continues.
      6 --   Run with --unsafe-io (needs both read and write permissions).
      7 
      8 writeThenRead = (path text :
      9   thenIO
     10     (writeFile path text)
     11     (readFile path))
     12 
     13 main = io <|
     14   (bind (writeThenRead "/tmp/tricu-demo.txt" "hello from tricu")
     15     (result :
     16       matchResult
     17         (err rest : putStrLn "error")
     18         (contents rest : putStrLn contents)
     19         result))