diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-09 18:16:41 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-09 18:16:41 +0200 |
| commit | cff5a0dfa89ab3a7f95512382cedf88f8e1709d1 (patch) | |
| tree | d6b49f3a49d623fdac1042b6de280886f587e5a1 /examples/try.milch | |
| parent | 0ec99f0ddba6084df7c78ff905849a9d3d0a3c5b (diff) | |
Fix purity issue
Diffstat (limited to 'examples/try.milch')
| -rw-r--r-- | examples/try.milch | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/examples/try.milch b/examples/try.milch index 68d6cc2..561e716 100644 --- a/examples/try.milch +++ b/examples/try.milch @@ -1,6 +1,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 -(try! Result/ex (. Result/ok read-file!) "does-not-exist.txt") +(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") |
