You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
makeFields in Control.Lens.TH fails for record types declared using ExistentialQuantification and GADTs syntax.
Tested with GHC 7.6.3 and current lens (I believe 4.0.5).
For example, the following fails with "verboseLenses: Expected the name of a record type".
data Foo a = (Num a) => Foo
{ _fooBarL :: a
}
makeFields ''Foo
This fails with the same error when using GADTs syntax.
I've also noticed silent failures when using makeLenses and makeClassy.
We should either fix the code or update the docs to reflect the limits of the TH methods.
The text was updated successfully, but these errors were encountered:
makeFields doesn't support a context before the constructor, which is usually related to existential quantification. In this case I expect you meant to write:
dataFoo=foralla.Numa=>Foo{_fooBarL::a}
and makeFields has needed documentation for a while. There's already a ticket for that if anyone wants to write the documentation.
makeLenses makes a best effort which ranges from Iso though Lens, Traversal, Fold, Getter, and nothing for each constructor depending on what makes sense. Silent "failure" is key since users will want the generated accessors for the constructors where it makes sense. The best that could be hoped for is this setter, which might be useful.
Unfortunately, you can't write combinators that can accept that version, which are reasonably parametric in Haskell, so all code working with it has to be written in direct style, and you can't compose them with (.), so I don't want to generate those either.
Also that version still isn't right as it makes the choice of b independent of the choice of a and it should be possible to pick b = a, but due to the ordering of the quantifiers it has to make its choice too early!
I think the right solution is to document that we can't provide lenses for existentially quantified fields, and to fix it so we supply lenses, traversals, getters and folds for the remaining fields if we can if we're skipping them just because of the context.
makeFields
in Control.Lens.TH fails for record types declared usingExistentialQuantification
andGADTs
syntax.Tested with GHC 7.6.3 and current
lens
(I believe 4.0.5).For example, the following fails with "verboseLenses: Expected the name of a record type".
This fails with the same error when using
GADTs
syntax.I've also noticed silent failures when using
makeLenses
andmakeClassy
.We should either fix the code or update the docs to reflect the limits of the TH methods.
The text was updated successfully, but these errors were encountered: