-
Notifications
You must be signed in to change notification settings - Fork 26
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
Manually Defining Lens with Type Constraints #3971
Comments
Yes, you have diagnosed the problem correctly and proposed the best solution. |
The type variable a is existentially quantified within the When pattern matching on I'm looking for a solution that allows me to keep the authors field generic while also being able to define functions and lenses that interact with it, but without exposing the internal type variable in an accessible way outside of |
Was this resolved? Reed told me that you both discussed this in person, but I'm not sure where things ended. I can have a look at this tomorrow if needed. |
Yes, I do need help. Although
|
After discussing this problem with Jason, we have identified two potential solutions. Upon reviewing the code, we noticed the following:
The Solution 1: Use a Concrete Type for authors in
Solution 2: Remove
I think Solution 1 is a more straightforward approach. Since the |
I'm not sure if Solution 2 will resolve anything anymore, because I think we still expect to create a lens for Regarding solution 1, the |
Yes, after reconsidering, I agree that Solution 2 might not fully address the issue. That said, switching to |
I use
makeClassyFor
to generate lenses for a data structureOldCodeSpec
. One of the fields,_authors
, has a constraintHasName a => [a]
. I encountered the following error:Here is the relevant part of my code:
It seems like Template Haskell cannot infer or generate the lens for
_authors
because of theHasName
constraint on the typea
. Should I manually define the lens forauthorsO
with theHasName
constraint while still usingmakeClassyFor
for the other fields, and resolve this issue with the type constraint in bothOldCodeSpec
andCodeSpec
?The text was updated successfully, but these errors were encountered: