diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-04 19:13:53 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-05 14:21:53 +0200 |
| commit | eb2e1e80b11825102c6fb80e04b0a0fffd4e63fb (patch) | |
| tree | ed685b7cdf72320d0758904846df1a5747393853 /examples | |
| parent | 77117fa515c5853b5f756d899db0ec9b502298e7 (diff) | |
Fix line numbers in script file tokens
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/types-concept.lisp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/types-concept.lisp b/examples/types-concept.lisp new file mode 100644 index 0000000..8359c6b --- /dev/null +++ b/examples/types-concept.lisp @@ -0,0 +1,34 @@ +; lowercase types: polymorphic +; everything else: monomorphic + +(type compose (\[ + (\[b] c) ; f + (\[a] b)] ; g + (\[a] c))) +(let! + compose (\[f g] (\[x] (f (g x))))) + +((compose (+ 1) (+ 2)) 3) + +(type id (\[a] a)) +(let! id (\[a] a)) + +(type mod (\[Int Int] Int)) +(let! mod (\[n k] + (- n (* k (/ n k))))) + +(type not (\[Bool] Bool)) +(let! not (\[b] + (match b + true false + false true))) + +(type is-even (\[Int] Bool)) +(let! is-even (\[n] + (match (mod n 2) + 0 true + 1 false))) + +; match cannot be type annotated because its variadic +; but the match above is inferred as this: +(type match (\[a a b a b] b)) |
