diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-06 17:37:43 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-06 17:37:43 +0200 |
| commit | e529e0e48c999fccb216bd3f3bc948abe22dbe76 (patch) | |
| tree | 18449b06ef564a2ec6a03dd53a4209b61bbd16e0 /examples/impure-concept.milch | |
| parent | e73ad00f44479e3065ccf12d07ca3ae22ca1f3f0 (diff) | |
Clean up examples, stdlib
Diffstat (limited to 'examples/impure-concept.milch')
| -rw-r--r-- | examples/impure-concept.milch | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/impure-concept.milch b/examples/impure-concept.milch index c767914..75c3bb7 100644 --- a/examples/impure-concept.milch +++ b/examples/impure-concept.milch @@ -5,8 +5,21 @@ ; The top-level context is impure but has special rules ; related to `import`, `let`, and other builtins. -; pure function +; this is a pure function (let f (\[x] x)) -; impure function -(let g! (\![x] (print! x))) +(f 10) ; works + +; this is an impure function +(let g! (\![x] (println! x))) + +(g! "foo") ; works + +; this is a pure function that tries to call an impure function +(let h (\[x] (g! x))) + +(h "bar") +; error: cannot call impure function in pure context +; when calling function g! at examples/purity-test.milch:19:15 +; in a function definition at examples/purity-test.milch:19:12 +; when calling function h at examples/purity-test.milch:21:1
\ No newline at end of file |
