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 found that when calling the/typed on a type that is missing the HasType constraint - e.g. when wiring up some code using a Reader and using this library for pulling values from there - produces less-than-desiderable type errors.
Minimal repro:
foo::env->Int
foo env = env ^. the @Int
..which produces this type error:
error:
• Overlapping instances for HasType Int env
arising from a use of ‘the’
Matching instances:
instance generic-lens-core-2.0.0.0:Data.Generics.Product.Internal.Typed.Context
a s =>
HasType a s
-- Defined in ‘Data.Generics.Product.Typed’
instance [overlapping] HasType a a
-- Defined in ‘Data.Generics.Product.Typed’
...plus one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
(The choice depends on the instantiation of ‘env’
To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
• In the second argument of ‘(^.)’, namely ‘the @Int’
In the expression: env ^. the @Int
In an equation for ‘foo’: foo env = env ^. the @Int
I would expect this to be:
about "missing constraint" instead of "overlapping instance"
a bit more actionable - e.g. I'd at least like GHC to suggest me to add the HasType constraint to the env, as it usually happens when trying to use a typeclass method on something that doesn't have the constraint.
Is there anything we could do about this here, or is this an inherent GHC limitation?
The text was updated successfully, but these errors were encountered:
Thanks for the great talk today 🙂
I found that when calling
the
/typed
on a type that is missing theHasType
constraint - e.g. when wiring up some code using aReader
and using this library for pulling values from there - produces less-than-desiderable type errors.Minimal repro:
..which produces this type error:
I would expect this to be:
HasType
constraint to theenv
, as it usually happens when trying to use a typeclass method on something that doesn't have the constraint.Is there anything we could do about this here, or is this an inherent GHC limitation?
The text was updated successfully, but these errors were encountered: