Closed typeless closed 4 years ago
The or-patterns with variables are implemented now.
type bar = union
`A int
`B int
`C int
`D (byte[:], int)
`E (byte[:], int)
`F (int, std.option(int))
`G (int, std.option(int))
;;
match `A 123
| `A x || `B x: std.put("good #4 {}\n", x)
| _: std.exit(1)
;;
// output: good #4 123
match `G (223, `std.Some 556)
| `F (x, `std.Some y) || `G (x, `std.Some y): std.put("good #5 x={} y={}\n", x, y)
| _: std.exit(1)
;;
// output good #5 x=223 y=556
This is looking pretty good. I'm going to poke a bit more at it, but I like the idea.
Examples: