@@ -44,7 +44,6 @@ import Data.Generics.Product.Internal.Fields
44import Data.Kind (Constraint, Type)
44import Data.Kind (Constraint, Type)
45import GHC.Generics
45import GHC.Generics
46import GHC.TypeLits (Symbol, ErrorMessage(..), TypeError)
46import GHC.TypeLits (Symbol, ErrorMessage(..), TypeError)
47−import Data.Type.Bool (If)
50-- >>> :set -XTypeApplications
49-- >>> :set -XTypeApplications
@@ -79,7 +78,7 @@ class HasField (field :: Symbol) s t a b | s field -> a where
79 -- >>> :t human
78 -- >>> :t human
80 -- human :: Human Bool
79 -- human :: Human Bool
81 -- >>> :t human & field @"other" .~ 42
80 -- >>> :t human & field @"other" .~ 42
82− -- human & field @"other" .~ 42 :: Num b => Human b
81+ -- human & field @"other" .~ 42 :: Num p => Human p
83 -- >>> human & field @"other" .~ 42
82 -- >>> human & field @"other" .~ 42
84 -- Human {name = "Tunyasz", age = 50, address = "London", other = 42}
83 -- Human {name = "Tunyasz", age = 50, address = "London", other = 42}
85 field :: Lens s t a b
84 field :: Lens s t a b
@@ -107,11 +106,7 @@ instance -- see Note [Changing type parameters]
107 , GHasField' field (Rep s) a
106 , GHasField' field (Rep s) a
108 , GHasField' field (Rep s') a'
107 , GHasField' field (Rep s') a'
109 , GHasField field (Rep s) (Rep t) a b
108 , GHasField field (Rep s) (Rep t) a b
110− , aa ~ PSub (Unify a' a)
109+ , '(t, b) ~ Infer s' a' a p
111− , '(t', b') ~ If (IsSingleton aa) '(Change s' (Fst (Head aa)) Skolem, Change a' (Fst (Head aa)) Skolem) '(s', a')
112− , t'' ~ UnProxied t'
113− , b'' ~ UnProxied b'
114− , '(b, t) ~ If (IsSingleton aa) '(Generalise b'' p, Generalise t'' p) '(b'', t'')
115 ) => HasField field s t a b where
110 ) => HasField field s t a b where
117 field f s = ravel (repLens . gfield @field) f s
112 field f s = ravel (repLens . gfield @field) f s