xref: /Universal-ctags/Units/parser-elm.r/elm-parameter-patterns.d/input.elm (revision 94e964efcdb54004e666334f92f6bee597c7ab96)
1-- Patterns can be found at https://elmprogramming.com/pattern-matching.html
2
3-- Simple tuple
4
5funcA (a1, _, a2) =
6    a1 + a2
7
8-- Multiple tuples
9
10funcB (b1, b2) (b3, b4) =
11    b1 + b2
12
13-- Records with named fields
14
15funcC {c1} {c2, c3} =
16   c1 + c2 + c3
17
18-- Constructor patterns
19
20funcD (D1Cons a b) (D2Cons a b, D3Cons a b) =
21    b + 1
22
23-- Combining the above
24
25funcE (D1Cons {a, b} c) d =
26    c + 1
27
28-- Using 'as' clauses
29
30funcF (D1Cons ({a, b} as ab) c) (d as d2) =
31    c + 1
32
33-- Make sure complex parameters can be used in anonymous functions
34
35funcG =
36    (\ (D1Cons {a, b} c) d -> a + b + c + d)
37