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

Test lens-compose / compose relationship #271

Open
jackfirth opened this issue Feb 4, 2016 · 1 comment
Open

Test lens-compose / compose relationship #271

jackfirth opened this issue Feb 4, 2016 · 1 comment

Comments

@jackfirth
Copy link
Owner

lens-compose should compose lenses in the same order as compose (it does currently, but it should be documented in tests that this order is preferred). This is to preserve the general assumption that lenses work like functions, but with the added "inverting" behavior for bidirectional programming. This assumption means the following should all be true:

  • When only using lens-view, lenses should operate like the getter functions they mimic. Thus, (lens-view (lens-compose l ...) target) should be equivalent to ((compose (lens-view l _) ...) target).
  • Applicable lenses behave like getters literally, so ((lens-compose l ...) target) should be equivalent to ((compose l ...) target) when using applicable lenses.
  • lens-thrush should invert direction just like thrush inverts function composition direction.

This issue is more to document why I made this ordering decision, as I recently noticed that Ramda's lensCompose uses the "wrong order".

@jackfirth
Copy link
Owner Author

Update: Ramda uses this order because Haskell does - Haskell does because it uses van Laarhoven lenses, which are functions and lens composition is the same as function composition. The details of the Laarhoven representation bring about the "composition inversion" behavior. I consider this an unfortunate consequence of the implementation, and Racket lenses are bound by no such implementation restrictions.

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