aboutsummaryrefslogtreecommitdiffstats
path: root/examples/try.milch
blob: 561e71629383c246130690d1fb21a7687f060dd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(import "core/common")
(import "core/result")

(let safe-read-file! (Result/safe! read-file!))

; calls read-file! and wraps the result in a Result/ok on success
; in case of error, calls Result/ex on the error string
(safe-read-file! "does-not-exist.txt")
(try! Result/ex (.! Result/ok read-file!) "examples/aoc22_1.txt")

(let pure-fn (\[x]
    (concat "foo" x)))

(print! (pure-fn "bar\n"))
(print! "nice\n")