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
I sometimes get error messages that resemble GHC missing instance messages but I don't understand what they actually mean. For example, the declaration
import Control.Lens (ReifiedLens(Lens))
foo :: HasPosition i s t a b => ReifiedLens s t a b
foo = Lens (position0 @i)
Gives this error:
src/Data/Generics/Product/Positions.hs:109:18: error:
* | No instance for ?Generic s?
| arising from a generic lens focusing on the field at
| position ?i? of type ?a? in ?s?
* In the first argument of `Lens', namely `position0'
In the expression: Lens (position0 @i)
In an equation for `foo': foo = Lens (position0 @i)
Could someone explain what this question mark bracketing means? There is already a Generic constraint on s.
The text was updated successfully, but these errors were encountered:
Adding a Generic s to fooErr's type signature confusingly has no effect on the error message.
fooErr::forallistab. (Generics, HasPositionistab) =>ReifiedLensstab
fooErr =Lens (position0 @i)
{- main.hs:60:14: error: [GHC-64725] • | No instance for ‘Generic s’ | arising from a generic lens focusing on the field at | position ‘i’ of type ‘a’ in ‘s’ • In the first argument of ‘Lens’, namely ‘(position0 @i)’ In the expression: Lens (position0 @i) In an equation for ‘fooErr’: fooErr = Lens (position0 @i)-}
Instead of saying that the instance will always fix the problem, type family NoGeneric could instead make a suggestion that usually works:
• | Suggested fix: `deriving instance Generic s'
| to satisfy a generic lens focusing on the field at
| position ‘i’ of type ‘a’ in ‘s’
• In the first argument of ‘Lens’, namely ‘(position0 @i)’
In the expression: Lens (position0 @i)
In an equation for ‘fooErr’: fooErr = Lens (position0 @i)
The original message is slightly better in that it doesn't suggest an unnecessary -XStandaloneDeriving.
I sometimes get error messages that resemble GHC missing instance messages but I don't understand what they actually mean. For example, the declaration
Gives this error:
Could someone explain what this question mark bracketing means? There is already a
Generic
constraint ons
.The text was updated successfully, but these errors were encountered: