tests/inputs/complex_union.derw
raw| 1 | -- https://github.com/eeue56/derw/blob/main/examples/complex_union.derw |
| 2 | type Animal = |
| 3 | Dog { name: string } |
| 4 | | Cat { lives: number } |
| 5 | |
| 6 | sayHiToPet: Animal -> string |
| 7 | sayHiToPet pet = |
| 8 | case pet of |
| 9 | Dog { name } -> |
| 10 | `Good boy ${name}!` |
| 11 | {- |
| 12 | Cat { lives } -> |
| 13 | "You have " + lives + " lives remaining." |
| 14 | -} |
| 15 | |
| 16 | main: void |
| 17 | main = |
| 18 | Dog { name: "roof" } |
| 19 | |> sayHiToPet |
| 20 | |> console.log |