| 1 | # Test lambda patterns |
| 2 | let |
| 3 | # Basic destructuring |
| 4 | f1 = { a, b }: a + b; |
| 5 | |
| 6 | # With default values |
| 7 | f2 = { a, b ? 10 }: a + b; |
| 8 | |
| 9 | # With ellipsis (extra fields allowed) |
| 10 | f3 = { a, ... }: a * 2; |
| 11 | |
| 12 | # Named pattern |
| 13 | f4 = arg@{ a, b }: a + b + arg.c; |
| 14 | |
| 15 | # Simple lambda (not a pattern) |
| 16 | f5 = x: x + 1; |
| 17 | in |
| 18 | { |
| 19 | # Test basic destructuring |
| 20 | test1 = f1 { a = 3; b = 4; }; |
| 21 | |
| 22 | # Test with defaults (provide both) |
| 23 | test2a = f2 { a = 5; b = 6; }; |
| 24 | |
| 25 | # Test with defaults (use default for b) |
| 26 | test2b = f2 { a = 5; }; |
| 27 | |
| 28 | # Test ellipsis (extra field ignored) |
| 29 | test3 = f3 { a = 7; extra = 999; }; |
| 30 | |
| 31 | # Test named pattern |
| 32 | test4 = f4 { a = 1; b = 2; c = 3; }; |
| 33 | |
| 34 | # Test simple lambda |
| 35 | test5 = f5 10; |
| 36 | } |