2021-09-16 21:08:45 +03:00
|
|
|
Tests that `if` statements can appear as list and tuple elements.
|
2021-09-16 04:26:39 +03:00
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2021-09-16 21:08:45 +03:00
|
|
|
> [ if true then 1 else 0 ]
|
|
|
|
|
|
|
|
> [ if true then 1 else 0, 1]
|
|
|
|
|
|
|
|
> [1, if true then 1 else 0]
|
|
|
|
|
|
|
|
> (if true then 1 else 0, 0)
|
|
|
|
|
|
|
|
> (0, if true then 1 else 0)
|
|
|
|
|
|
|
|
> (1)
|
|
|
|
|
|
|
|
> (1,2)
|
|
|
|
|
|
|
|
> (1,2,3)
|
|
|
|
|
|
|
|
> [1,2,3]
|
|
|
|
|
|
|
|
> []
|
|
|
|
|
|
|
|
> [1]
|
|
|
|
|
|
|
|
> [1,2]
|
|
|
|
|
|
|
|
> [1,2,3]
|
|
|
|
|
2021-09-17 05:35:15 +03:00
|
|
|
> [
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3
|
|
|
|
]
|
|
|
|
|
|
|
|
> [
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,]
|
|
|
|
|
|
|
|
> (1,2,3,)
|
|
|
|
|
|
|
|
> (1,
|
|
|
|
2,)
|
|
|
|
|
2021-09-17 16:24:37 +03:00
|
|
|
structural ability Zoot where zoot : ()
|
|
|
|
|
|
|
|
Zoot.handler : Request {Zoot} a -> a
|
|
|
|
Zoot.handler = cases
|
|
|
|
{ a } -> a
|
|
|
|
{ zoot -> k } -> handle !k with Zoot.handler
|
|
|
|
|
|
|
|
fst = cases (x,_) -> x
|
|
|
|
|
|
|
|
> List.size
|
|
|
|
[ if true then (x y -> y)
|
|
|
|
else handle (x y -> x) with fst (Zoot.handler, 42),
|
|
|
|
cases a, b -> a Nat.+ b, -- multi-arg cases lambda
|
|
|
|
cases x, y -> x Nat.+ y
|
|
|
|
]
|
2021-09-16 04:26:39 +03:00
|
|
|
```
|
|
|
|
|