mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
`cmark`’s pretty-printer matches our output pretty well, with a few differences: - it puts a space between the fence and the info string for in code blocks; - it prefers `-` over `*` for bulleted lists (as do I) and it indents them; - it `\`-escapes certain chars very conservatively; - it prefers indented/unfenced code blocks if there is no info string; and - it prefers `*` over `_` (unlike any sane person). This also shows how the change fixes a number of issues: - fix2158-1.output.md also illustrates how this change fixes #1809; - alias-many.output.md and input-parse-errors.output.md show how fenced code blocks without an info string would use the beginning of the content as the info string; - transcripts-round-trip/main.output.md shows how output blocks for generated `unison` stanzas (which could contain nested fenced blocks) might not have long-enough fences; and - error-messages.output.md and generic-parse-errors.output.md show how Unison errors were reported on the wrong line number (and thus the printed error lines were also incorrect).
63 lines
751 B
Markdown
63 lines
751 B
Markdown
Tests that `if` statements can appear as list and tuple elements.
|
|
|
|
``` 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]
|
|
|
|
> [
|
|
1,
|
|
2,
|
|
3
|
|
]
|
|
|
|
> [
|
|
1,
|
|
2,
|
|
3,]
|
|
|
|
> (1,2,3,)
|
|
|
|
> (1,
|
|
2,)
|
|
|
|
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
|
|
]
|
|
```
|
|
|