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

Remove RequireQualifiedAccess from Optic module #59

Open
cmeeren opened this issue Mar 30, 2021 · 6 comments
Open

Remove RequireQualifiedAccess from Optic module #59

cmeeren opened this issue Mar 30, 2021 · 6 comments

Comments

@cmeeren
Copy link

cmeeren commented Mar 30, 2021

I'd like to open Optic so I can just do x |> set foo_ "bar" instead of x |> Optic.set foo_ "bar", but Optic is marked with RequireQualifiedAccessAttribute.

This may be relevant for other modules as well; haven't checked.

@varon
Copy link
Contributor

varon commented Apr 5, 2021

Typically you'd use the operators for this instead.

@cmeeren
Copy link
Author

cmeeren commented Apr 5, 2021

Can you do x |> set a_ "a" |> set b_ "b" |> ... with operators?

In any case, I often prefer functions over custom operators for legibility reasons, and it's nice to have the option. 😊 Particularly since The change is trivial.

@et1975
Copy link

et1975 commented Apr 6, 2021

As long as we are throwing personal preferences in, I'm the opposite - I prefer explicit module names, especially when the chance of name collision is high and Lens and Prism would typically be used in the same context.
For personal preferences auto-opened Prelude in your project file is the way to go. That would be ideal place to alias functions you want into an auto-opened module.

@cmeeren
Copy link
Author

cmeeren commented Apr 6, 2021

Sure, but removing RequireQualifiedAccessAttribute doesn't change anything for you or other users who prefer explicit module names. It's a tiny and fully backwards compatible change that doesn't impact anyone except those that choose to make use of it. It makes Aether more flexible without adding any maintenance burden or impacting those who aren't interested.

@varon
Copy link
Contributor

varon commented Apr 6, 2021

@cmeeren - the entire way Aether is written, even down to the type level is designed to be maximally flexible and compatible.

In general, qualified access serves as a stopgap measure in the absence of proper HKT support, much like List, Set and Map do.

The library (in general) tries to provide some conventions on how to do things; with the operators offering very decent syntax for most tasks. if you'd like to write your own get/set functions, they're incredibly trivial to do in your own prelude.

@cmeeren
Copy link
Author

cmeeren commented Apr 6, 2021

stopgap measure

Against what, would be my question. I don't see the harm in allowing the module to be opened. It won't impact anyone except those users who deliberately try to do it.

much like List, Set and Map do.

I don't think it's a fair comparison; those modules (and Option, Array, etc.) contain a lot of functions, many of which have the same names (since they're all functors/monads/etc.). Optic contains get, map, and set (and hopefully over at some point, #57).

and Lens and Prism would typically be used in the same context.

This issue is only about Optic, not Lens and Prism.


In any case, though I stand by my position that this would be a convenience, it's a fairly minor one (as you point out), and not something I personally feel is worth further discussion. Feel free to close. 🙂

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

3 participants