Update demos and adds <|
This commit is contained in:
16
demos/interactionTrees/safeRead.tri
Normal file
16
demos/interactionTrees/safeRead.tri
Normal file
@@ -0,0 +1,16 @@
|
||||
!import "../../lib/base.tri" !Local
|
||||
!import "../../lib/list.tri" !Local
|
||||
!import "../../lib/io.tri" !Local
|
||||
|
||||
-- readFile returns a Result. matchResult branches on ok / err.
|
||||
-- Run with --allow-read PATH or --unsafe-io.
|
||||
|
||||
safeRead = (path :
|
||||
bind (readFile path)
|
||||
(result :
|
||||
matchResult
|
||||
(err rest : pure "ERROR: Unable to read file")
|
||||
(contents rest : pure contents)
|
||||
result))
|
||||
|
||||
main = io (safeRead "demos/interactionTrees/greet.tri")
|
||||
Reference in New Issue
Block a user