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

Add generic prisms #137

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

amesgen
Copy link

@amesgen amesgen commented Nov 6, 2021

Description of the change

Generic prisms, inspired by Haskell's generic-lens, see _Ctor.

  • All names are subject to bikeshedding.
  • Type inference is not optimal. For example, _CC in the first example in the test suite can not be inlined (without a type annotation), but _BB can be inlined without a type signature in the second one. Maybe there are some PureScript-specific tricks (maybe some fundep stuff) to get around this, but I think this PR would be useful even with this slightly suboptimal inferability.

Checklist:

  • Added the change to the changelog's "Unreleased" section with a link to this PR and your username
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation in the README and/or documentation directory
  • Added a test for the contribution (if applicable)

@MonoidMusician
Copy link
Contributor

Have you seen https://github.com/LiamGoodacre/purescript-generics-rep-optics? It also provides optics based on generics-rep.

@amesgen
Copy link
Author

amesgen commented Nov 7, 2021

Ah cool, I was not aware of that library. It seems to need a few slight changes to compile again, and has some differences (like not supporting constructors with zero or more than one argument). While I thought it would be nice to have something dual to field in profunctor-lenses, one other route would be to create a PR to https://github.com/LiamGoodacre/purescript-generics-rep-optics.

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

Successfully merging this pull request may close these issues.

2 participants