-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Recursing with typed as well as types #134
Comments
I implemented this feature a while ago (it might be on a branch? I can't remember), but never merged it because of how brittle I thought it was. Since the lens focuses on a single element, it only makes sense if the whole type has exactly one value of that type (as your A6 example shows). We have to look deep, and if any type in the tree has no Generic instance then the procedure fails. (though the "types" combinator suffers from the same issue, and that has a workaround) I thought about maybe taking an additional numeric argument to specify the maximum depth, but that seemed inelegant. I won't have too much time/energy in the near future to work on it though. I'll keep it in mind the next time I come back here! |
Makes sense, thanks! I'll have a peruse and see if it's on a branch somewhere :) |
I just bumped into this -- I wanted a setup where I could "peel off" layers of the environment in a MonadReader (the regular Has pattern I think), started doing it manually, found that generic-lens could automate it for me. I think a deep search would give me the exact functionality I want, since if I did end trying to use a Has instance where the type has != 1 value of the type, I'd want a type error (in other words, if I was doing it manually, I wouldn't have written such an instance). If I could receive a few pointers for this I might be able to look into it? Not done generics before though...! |
I noticed there was #75 which seems to suggest it's possible, but having scoured the linked issues and pull requests I can't quite find out how.
In retrospect, I think this probably falls into problems with sum types; there is no
Lens' (Maybe A1) B
...The text was updated successfully, but these errors were encountered: