robrix / Prelude

Swift µframework of simple functional programming tools
MIT License
409 stars 26 forks source link

Partial backward application with closure params #19

Closed robrix closed 9 years ago

robrix commented 9 years ago

@dnalot makes an interesting and compelling case for <| to apply a closure on the right hand side to a flipped binary function on the left hand side. (Technically the proposal would apply to any binary function and matching operand, but that’s the motivating case.)

For example, this would allow:

map <| { $0.description }

Partial application is of general utility, and flippedness in particular allows the closure to be applied to the appropriate argument of the map, since Swift takes block parameters in trailing position to enable trailing syntax, at the cost of ease of curried application.