-
-
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
A different approach to fields #136
Comments
There might be some subtleties I'm missing, but I think we already a have a similar lens: generic-lens/generic-lens/src/Data/Generics/Product/Fields.hs Lines 112 to 124 in 8e1fc7d
with the instance defined as generic-lens/generic-lens/src/Data/Generics/Product/Fields.hs Lines 167 to 168 in 8e1fc7d
generic-lens/generic-lens-core/src/Data/Generics/Product/Internal/Fields.hs Lines 44 to 50 in 8e1fc7d
This uses generic-lens/generic-lens-core/src/Data/Generics/Internal/Families/Changing.hs Lines 133 to 137 in 8e1fc7d
This machinery looks similar to For concrete types this works out quite well, but in my experience, the fundeps come in really handy in a polymorphic context (like when a function has a |
It's not quite the same, no. I'm talking about something like class (Similar s t, FindFieldType fld s ~ 'Just a, FindFieldType fld t ~ 'Just b) => Fielded fld s t a b where
fielded :: Lens s t a b This gives you |
My version makes an a priori assumption over |
The purpose of We run Assuming that class ... => Fielded fld s t a b | fld s -> a, fld t -> s where in other words, we could perhaps add those fundeps to |
Data.Generics.Product.Fields
forcess field b -> t, t field a -> s
in a rather complicated way. But this fundep isn't even always desirable. For example, thegetConst
lens is quite reasonably type-changing.A different approach:
coercible-utils
to imposeSimilar s t
, which means they both have the same type constructor and kind arguments.s field b -> Rep t
andt field a -> Rep s
for each concrete type fall out of the constraint solving.I think this way is much simpler, and it avoids unnecessary constraints; inference should be quite good, handling all non-phantom types.
If you don't want to do that in this package, let me know and I'll make my own for that.
The text was updated successfully, but these errors were encountered: