unison/unison-src/transcripts/fix-2258-if-as-list-element.output.md

63 lines
751 B
Markdown
Raw Permalink Normal View History

Tests that `if` statements can appear as list and tuple elements.
2021-09-16 04:26:39 +03:00
``` unison
> [ 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
```