Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obj position in argument order #154

Open
jariji opened this issue Jun 20, 2024 · 1 comment
Open

obj position in argument order #154

jariji opened this issue Jun 20, 2024 · 1 comment

Comments

@jariji
Copy link

jariji commented Jun 20, 2024

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?

@jw3126
Copy link
Member

jw3126 commented Jun 21, 2024

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 = val and set(@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 set method as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants