===
[Pattern matching] simple
===
> match f with
    "Pie"     -> "slice"
    "Coffee"  -> "cup"
    "Soup"    -> "bowl"
    "Pancake" -> "stack"
    _         -> "???"
---
(unison
    (watch_expression
        (match)
        (wordy_id)
        (with)
        (pattern (literal_text) (arrow_symbol) (literal_text))
        (pattern (literal_text) (arrow_symbol) (literal_text))
        (pattern (literal_text) (arrow_symbol) (literal_text))
        (pattern (literal_text) (arrow_symbol) (literal_text))
        (pattern (blank_pattern) (arrow_symbol) (literal_text))))
===
[Pattern matching] with variables
===
> match guess with
    42 -> "magic"
    n -> "not magic"
---
(unison
    (watch_expression
        (match)
        (wordy_id)
        (with)
        (pattern (nat) (arrow_symbol) (literal_text))
        (pattern (constructor_or_variable_pattern (wordy_id)) (arrow_symbol) (literal_text))))
===
[Pattern matching] guard patterns
===
> match a with
    oneTwo | (oneTwo === 1) || (oneTwo === 2) -> "one or two"
    threeFour | (threeFour === 3) || (threeFour === 4) -> "three or four"
    fiveSix | (fiveSix === 5) || (fiveSix === 6) -> "five or six"
    _ -> "no match"
> match x with
     0 | 1 == 2 -> 123
---
(unison
    (watch_expression
        (match)
        (wordy_id)
        (with)
        (pattern (constructor_or_variable_pattern (wordy_id)) (guard (pipe) (tuple_or_parenthesized (function_application (wordy_id) (operator) (nat))) (or) (tuple_or_parenthesized (function_application (wordy_id) (operator) (nat))) (arrow_symbol) (literal_text)))
        (pattern (constructor_or_variable_pattern (wordy_id)) (guard (pipe) (tuple_or_parenthesized (function_application (wordy_id) (operator) (nat))) (or) (tuple_or_parenthesized (function_application (wordy_id) (operator) (nat))) (arrow_symbol) (literal_text)))
        (pattern (constructor_or_variable_pattern (wordy_id)) (guard (pipe) (tuple_or_parenthesized (function_application (wordy_id) (operator) (nat))) (or) (tuple_or_parenthesized (function_application (wordy_id) (operator) (nat))) (arrow_symbol) (literal_text)))
        (pattern (blank_pattern) (arrow_symbol) (literal_text)))
    (watch_expression (match) (wordy_id) (with)
        (pattern (nat) (guard (pipe) (function_application (nat) (operator) (nat)) (arrow_symbol) (nat)))))
===
[Patterns] match/with
===
> match x with x -> x
> match x with 0 -> 1
> match x with
    0 -> 1
> match +0 with
      +0 -> -1
> match x with
      x -> 1
      2 -> 7
      _ -> 3
      Tuple.Cons x y -> x + y
      Tuple.Cons (Tuple.Cons x y) _ -> x + y 
> match x with
      0 ->
        z = 0
        z
---
(unison
    (watch_expression (match) (wordy_id) (with) (pattern (constructor_or_variable_pattern (wordy_id)) (arrow_symbol) (wordy_id)))
    (watch_expression (match) (wordy_id) (with) (pattern (nat) (arrow_symbol) (nat)))
    (watch_expression (match) (wordy_id) (with) (pattern (nat) (arrow_symbol) (nat)))
    (watch_expression (match) (int) (with) (pattern (int) (arrow_symbol) (int)))
    (watch_expression (match) (wordy_id) (with) 
        (pattern (constructor_or_variable_pattern (wordy_id)) (arrow_symbol) (nat))
        (pattern (nat) (arrow_symbol) (nat))
        (pattern (blank_pattern) (arrow_symbol) (nat))
        (pattern (constructor_or_variable_pattern (path) (wordy_id) (constructor_or_variable_pattern (wordy_id)) (constructor_or_variable_pattern (wordy_id))) (arrow_symbol) (function_application (wordy_id) (operator) (wordy_id)))
        (pattern (constructor_or_variable_pattern (path) (wordy_id) 
            (tuple_pattern (constructor_or_variable_pattern (path) (wordy_id) (constructor_or_variable_pattern (wordy_id)) (constructor_or_variable_pattern (wordy_id))))
            (blank_pattern))
            (arrow_symbol) 
            (function_application (wordy_id) (operator) (wordy_id))))
    (watch_expression (match) (wordy_id) (with)
        (pattern (nat) (arrow_symbol)
            (term_declaration (term_definition (wordy_id) (kw_equals) (nat)))
            (wordy_id)))
)
===
[Patterns] list patterns
===
> match x with
     [] -> 0
     [1] -> 1
     2 +: _ -> 2
     _ :+ 3 -> 3
     [4] ++ _ -> 4
     _ ++ [5] -> 5
     _ -> -1
---
(unison (watch_expression (match) (wordy_id) (with)
        (pattern (literal_list_pattern) (arrow_symbol) (nat))
        (pattern (literal_list_pattern (nat)) (arrow_symbol) (nat))
        (pattern (head_tail_list_pattern (nat) (blank_pattern)) (arrow_symbol) (nat))
        (pattern (init_last_tail_pattern (blank_pattern) (nat)) (arrow_symbol) (nat))
        (pattern (concat_list_pattern (literal_list_pattern (nat)) (blank_pattern)) (arrow_symbol) (nat))
        (pattern (concat_list_pattern (blank_pattern) (literal_list_pattern (nat))) (arrow_symbol) (nat))
        (pattern (blank_pattern) (arrow_symbol) (int))))
===
[Patterns] cases
===
> cases x -> x
> cases
     [] -> 0
     [x] -> 1
     _ -> 2
> cases
     0 ->
       z = 0
       z
---
(unison
    (watch_expression (cases) (pattern (constructor_or_variable_pattern (wordy_id)) (arrow_symbol) (wordy_id)))
    (watch_expression (cases)
        (pattern (literal_list_pattern) (arrow_symbol) (nat))
        (pattern (literal_list_pattern (constructor_or_variable_pattern (wordy_id))) (arrow_symbol) (nat))
        (pattern (blank_pattern) (arrow_symbol) (nat)))
    (watch_expression (cases)
        (pattern (nat) (arrow_symbol)
            (term_declaration (term_definition (wordy_id) (kw_equals) (nat)))
            (wordy_id))))