
Hi Li-yao,
In theory, I should be able to make SomePerson an instance of HasPerson, define
person :: Lens' SomePerson (Person sex)
I wonder what you mean by that, since you highlight the issue just after.
what I meant is that defining that instance is the intended purpose of the HasPerson type class. That entire construct exists so that -- in theory -- I can make SomePerson an instance of it and use it exactly the same way as I would use a 'Person'. It's just that the theory doesn't work out. I can't make SomePerson an instance of HasPerson even though it clearly *has* a Person inside that I *can* access. Now, I understand why SomePerson cannot be an instance of HasPerson. What I wonder is whether there is maybe a way to define HasPerson such that I *can* make SomePerson and instance of it and use it like I would use a Person type as far as the lenses are concerned. I have outlined one such solution in my posting, but that solution feels awkward because it requires quite a bit of glue code. So, I was hoping that someone could point me to a better way to define the *class* in order to make it applicable to SomePerson in the way HasPerson is intended to be used. Best regards, Peter