grain
grain copied to clipboard
feat(compiler)!: Partial function application
Partial function application
let add = (x, y) => x + y
let add1 = partial add(1, _)
assert add1(2) == 3
let printValues = (x, y, z=3) => {
print(x)
print(y)
print(z)
}
let printSome = partial printValues(y=2, _, z=_)
printSome(1) // prints 1, 2, 3
Closes #402
TODO:
- [x] Make precedence of
partialtighter to allowx |> partial add(_, y)without parentheses around thepartialexpression - [x] ~~Decide if this feature should be supported for infix functions~~ - doesn't seem particularly useful so will not do in this PR
Marked this as breaking because of the new keywords.