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

Document that application of view to a term of type Lens does not always type check. #1061

Open
kindaro opened this issue Mar 11, 2024 · 0 comments

Comments

@kindaro
Copy link

kindaro commented Mar 11, 2024

As we found out in #1059, lens does not promise that even its basic features will work with a term of type Lens that is not a well-behaved lens. It seems that, specifically, the terms needed to state that a lens is well-behaved must type check. This is surprising because:

  • A Lens is nothing but a van Laarhoven presentation of a lens, for which the basic features would work, be it well-behaved or not well-behaved.
  • A lens can be handy even while not being well-behaved. There is a whole book on this topic.

It would be fantastic if one did not have to follow Edward's blog post to infer the reasoning behind view not type checking. To this end I say we should add a note to Control.Lens.Lens, right after the definition of the type Lens. Currently, it says:

A Lens is actually a lens family as described in http://comonad.com/reader/2012/mirrored-lenses/.

I cannot say I understand what a lens family is and what the implications of something being a lens family are. Edward's blog post does not contain a clear, compact definition, and to infer one would take days of careful study. Even if Edward's blog post did contain a clear, compact definition, it would go offline one day. The bits needed to understand how a Lens can and cannot be wielded should be given right at its definition.

We should say:

  1. A lens must be of such and such specific type.
  2. Otherwise, some stuff like view will break.

I do not exactly understand what «such and such specific type» is.

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

1 participant