`obj` position in argument order
Higher-order functions like map(f, obj) usually put the data argument last. In Accessors, it's usually hof(obj, optic, val) or modify(f, obj, optic) where the data argument comes earlier, which I didn't expect. I'm interested what explains this decision?
In very early Setfield.jl commits the order was actually like you suggested. However:
- I found it confusing that the order is switched in
@set obj.field = valandset(@lens(_.field), obj, val) - There is one good reason to put functions first, namely do blocks. However, this advantage is lost if the first argument is an optic.
- Also back in the day I missed/did not take seriously enough the viewpoint, that a lens is just a function that has a
setmethod as well.
This does bother me a bit. I always expect it to be
modify(cumsum, reverse, xs)
like all the other functional programming things and I have to check the docs to remember that the optic comes last and the data comes in the middle. I'm happy with the function coming first.
I personally also find the current order totally reasonable. Anyway, there's probably no objective better/worse here, and it's not worth a breaking change.