@@ -45,6 +45,7 @@ import GHC.TypeLits (Symbol, TypeError, ErrorMessage (..))
45import Data.Generics.Internal.VL.Prism
45import Data.Generics.Internal.VL.Prism
46import Data.Generics.Internal.Profunctor.Iso
46import Data.Generics.Internal.Profunctor.Iso
47import Data.Generics.Internal.Profunctor.Prism (prismPRavel)
47import Data.Generics.Internal.Profunctor.Prism (prismPRavel)
48+import Data.Generics.Internal.Errors
50-- == /Running example:/
51-- == /Running example:/
@@ -70,7 +71,7 @@ import Data.Generics.Internal.Profunctor.Prism (prismPRavel)
70-- , age :: Age
71-- , age :: Age
71-- , fieldA :: a
72-- , fieldA :: a
73−-- deriving (Generic, Show)
74+-- deriving Show
74-- type Name = String
75-- type Name = String
75-- type Age = Int
76-- type Age = Int
76-- dog, cat, duck :: Animal Int
77-- dog, cat, duck :: Animal Int
@@ -128,20 +129,24 @@ instance
128 ( Generic s
129 ( Generic s
129 , ErrorUnless ctor s (HasCtorP ctor (Rep s))
130 , ErrorUnless ctor s (HasCtorP ctor (Rep s))
130 , GAsConstructor' ctor (Rep s) a
131 , GAsConstructor' ctor (Rep s) a
133+ (NoGeneric s '[ 'Text "arising from a generic prism focusing on the "
134+ ':<>: QuoteType ctor ':<>: 'Text " constructor of type " ':<>: QuoteType a
135+ , 'Text "in " ':<>: QuoteType s])
131 ) => AsConstructor' ctor s a where
137 ) => AsConstructor' ctor s a where
132 _Ctor' eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
138 _Ctor' eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
133 {-# INLINE[2] _Ctor' #-}
139 {-# INLINE[2] _Ctor' #-}
138− , ErrorUnless ctor s (HasCtorP ctor (Rep s))
142+ ( ErrorUnless ctor s (HasCtorP ctor (Rep s))
139 , GAsConstructor' ctor (Rep s) a -- TODO: add a test similar to #62 for prisms
143 , GAsConstructor' ctor (Rep s) a -- TODO: add a test similar to #62 for prisms
140 , GAsConstructor' ctor (Rep (Indexed s)) a'
144 , GAsConstructor' ctor (Rep (Indexed s)) a'
141 , GAsConstructor ctor (Rep s) (Rep t) a b
145 , GAsConstructor ctor (Rep s) (Rep t) a b
142 , t ~ Infer s a' b
146 , t ~ Infer s a' b
143 , GAsConstructor' ctor (Rep (Indexed t)) b'
147 , GAsConstructor' ctor (Rep (Indexed t)) b'
144 , s ~ Infer t b' a
148 , s ~ Infer t b' a
149+ , AsConstructor0 ctor s t a b
145 ) => AsConstructor ctor s t a b where
150 ) => AsConstructor ctor s t a b where
147 _Ctor = _Ctor0 @ctor
152 _Ctor = _Ctor0 @ctor
@@ -152,15 +157,14 @@ instance {-# OVERLAPPING #-} AsConstructor ctor (Void1 a) (Void1 b) a b where
152 _Ctor = undefined
157 _Ctor = undefined
157− , ErrorUnless ctor s (HasCtorP ctor (Rep s))
160+ ( ErrorUnless ctor s (HasCtorP ctor (Rep s))
158 , GAsConstructor' ctor (Rep s) a -- TODO: add a test similar to #62 for prisms
161 , GAsConstructor' ctor (Rep s) a -- TODO: add a test similar to #62 for prisms
159 , GAsConstructor' ctor (Rep (Indexed s)) a'
162 , GAsConstructor' ctor (Rep (Indexed s)) a'
160 , GAsConstructor ctor (Rep s) (Rep t) a b
163 , GAsConstructor ctor (Rep s) (Rep t) a b
161 , GAsConstructor' ctor (Rep (Indexed t)) b'
164 , GAsConstructor' ctor (Rep (Indexed t)) b'
162 , UnifyHead s t
165 , UnifyHead s t
163 , UnifyHead t s
166 , UnifyHead t s
167+ , AsConstructor0 ctor s t a b
164 ) => AsConstructor_ ctor s t a b where
168 ) => AsConstructor_ ctor s t a b where
166 _Ctor_ = _Ctor0 @ctor
170 _Ctor_ = _Ctor0 @ctor
@@ -173,6 +177,11 @@ instance
173 ( Generic s
177 ( Generic s
174 , Generic t
178 , Generic t
175 , GAsConstructor ctor (Rep s) (Rep t) a b
179 , GAsConstructor ctor (Rep s) (Rep t) a b
181+ (NoGeneric s '[ 'Text "arising from a generic prism focusing on the "
182+ ':<>: QuoteType ctor ':<>: 'Text " constructor of type " ':<>: QuoteType a
183+ , 'Text "in " ':<>: QuoteType s])
176 ) => AsConstructor0 ctor s t a b where
185 ) => AsConstructor0 ctor s t a b where
177 _Ctor0 = prismRavel (prismPRavel (repIso . _GCtor @ctor))
186 _Ctor0 = prismRavel (prismPRavel (repIso . _GCtor @ctor))
178 {-# INLINE[2] _Ctor0 #-}
187 {-# INLINE[2] _Ctor0 #-}