@@ -67,7 +67,7 @@ import GHC.TypeLits (Symbol, ErrorMessage(..), TypeError)
69-- |Records that have a field with a given name.
69-- |Records that have a field with a given name.
70−class HasField (field :: Symbol) s t a b | s field -> a where
70+class HasField (field :: Symbol) s t a b | s field -> a, s field b -> t where
71 -- |A lens that focuses on a field with a given name. Compatible with the
71 -- |A lens that focuses on a field with a given name. Compatible with the
72 -- lens package's 'Control.Lens.Lens' type.
72 -- lens package's 'Control.Lens.Lens' type.
@@ -106,7 +106,7 @@ instance -- see Note [Changing type parameters]
106 , GHasField' field (Rep s) a
106 , GHasField' field (Rep s) a
107 , GHasField' field (Rep s') a'
107 , GHasField' field (Rep s') a'
108 , GHasField field (Rep s) (Rep t) a b
108 , GHasField field (Rep s) (Rep t) a b
109− , '(t, b) ~ Infer s' a' a p
109+ , '(t, b) ~ Infer s' a' a (PickTv a' b)
110 ) => HasField field s t a b where
110 ) => HasField field s t a b where
112 field f s = ravel (repLens . gfield @field) f s
112 field f s = ravel (repLens . gfield @field) f s
@@ -115,6 +115,9 @@ instance -- see Note [Changing type parameters]
115instance {-# OVERLAPPING #-} HasField f (Void2 t a) t a b where
115instance {-# OVERLAPPING #-} HasField f (Void2 t a) t a b where
116 field = undefined
116 field = undefined
118+instance {-# OVERLAPPING #-} HasField f (Void1 a) (Void1 b) a b where
118type family ErrorUnless (field :: Symbol) (s :: Type) (contains :: Bool) :: Constraint where
121type family ErrorUnless (field :: Symbol) (s :: Type) (contains :: Bool) :: Constraint where
119 ErrorUnless field s 'False
122 ErrorUnless field s 'False
120 = TypeError
123 = TypeError