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

Consider adding HasConstraints back #109

Open
kcsongor opened this issue Feb 12, 2020 · 1 comment
Open

Consider adding HasConstraints back #109

kcsongor opened this issue Feb 12, 2020 · 1 comment
Milestone

Comments

@kcsongor
Copy link
Owner

I removed this feature from 2.0.0.0 because the motivation for it was quite weak and I wasn't happy with the interface. However, if we can find a more consistent story and some motivating examples, it would be great to add it back.

@kcsongor kcsongor added this to the 2.1.0.0 milestone Feb 12, 2020
@AriFordsham
Copy link

AriFordsham commented Aug 30, 2022

I found HasConstraints insufficiently general.

  • It supports (at maximum granularity) traversing all fields of a given type, even in different positions.
  • It supports fields with a given type parameter, even in the place of other fields of the same type.
  • But it cannot support traversing a specific field e.g. in a recursive structure, without traversing another of the same type.

Example: a datatype for the UCS-2 encoding (https://en.wikipedia.org/wiki/Universal_Coded_Character_Set)

data UCS2
  = Nil
  | Cons
  { ucs2First :: Word8
  , ucs2Second :: Word8
  , ucs2Tail :: UCS2
  }

I cannot use HasConstraints (or any generic-lens combinator, if I were to omit the field labels) to traverse just the ucs2First field.

I would love to see what a sufficiently general solution would look like.

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

2 participants