tweag / cooked-validators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a reason to use the optics package?

martyall opened this issue · comments

Is your feature request related to a problem? Please describe.
The constraint optics are defined using optics instead of the types from lens. I think it is doing this because it's a lighter weight package? Since lens is by far more popular in downstream dependencies, it often forces projects to depend on both libraries anyway.

Describe the solution you'd like
What about using microlens instead? Possibly even lighter weight and out-of-the-box compatible with lens.

The reason why we chose optics is that it's more convenient for our use case, yes.

More concretely, there are a few reasons why I think that optics is nicer than lens, which are summarised in the announcement of the library. The most salient of those reasons here is probably that optics, being implemented in terms of the profunctor- and not the van Laarhoven encoding (which lens uses), allows for /affine/ optics, i.e. ones that are known on the type level to have at most one focus. That's something I very much wanted to use.

So, in a sense, we use optics for ideological reasons, and not to reduce the dependency footprint.