@@ -169,16 +169,40 @@ instance
169169 definitionId = definitionIdTuple3 <> definitionId @ a <> definitionId @ b <> definitionId @ c
170170
171171{-| Compile-time error that happens when a type couldn't be unrolled
172- ('Unroll' TF is "stuck") -}
172+ ('Unroll' TF is "stuck").
173+
174+ Note: This error commonly occurs when using 'DefinitionsFor (UnrollAll \'[a])'
175+ with an abstract type variable 'a'. Type families like 'UnrollAll' must be fully
176+ evaluated at compile time, which is not possible when the type is not yet known. -}
173177type family UnrollIsStuckError x where
174178 UnrollIsStuckError x =
175- GHC. TypeError (GHC. Text " No instance: " GHC. :<>: GHC. ShowType (HasBlueprintDefinition x ))
179+ GHC. TypeError
180+ ( GHC. Text " Cannot unroll type '"
181+ GHC. :<>: GHC. ShowType x
182+ GHC. :<>: GHC. Text " '."
183+ GHC. :$$: GHC. Text " The 'Unroll' type family is stuck because:"
184+ GHC. :$$: GHC. Text " - The type may be abstract (a type variable), or"
185+ GHC. :$$: GHC. Text " - It lacks a 'HasBlueprintDefinition' instance, or"
186+ GHC. :$$: GHC. Text " - It lacks a 'Generic' instance for default unrolling."
187+ GHC. :$$: GHC. Text " "
188+ GHC. :$$: GHC. Text " Tip: 'DefinitionsFor (UnrollAll ts)' requires all types in 'ts'"
189+ GHC. :$$: GHC. Text " to be concrete at compile time. Polymorphic constraints like"
190+ GHC. :$$: GHC. Text " 'DefinitionsFor (UnrollAll '[a])' cannot be used as superclass"
191+ GHC. :$$: GHC. Text " constraints because 'a' is not known when the class is defined."
192+ )
176193
177194{-| Compile-time error that happens when type's generic representation is not defined
178195('Rep' TF is "stuck") -}
179196type family RepIsStuckError x where
180197 RepIsStuckError x =
181- GHC. TypeError (GHC. Text " No instance: " GHC. :<>: GHC. ShowType (Generic x ))
198+ GHC. TypeError
199+ ( GHC. Text " Cannot derive generic representation for type '"
200+ GHC. :<>: GHC. ShowType x
201+ GHC. :<>: GHC. Text " '."
202+ GHC. :$$: GHC. Text " Add 'deriving Generic' to enable automatic blueprint unrolling,"
203+ GHC. :$$: GHC. Text " or provide a manual 'HasBlueprintDefinition' instance with"
204+ GHC. :$$: GHC. Text " an explicit 'Unroll' type instance."
205+ )
182206
183207-- | Same as 'Unroll' but with a nicer error message
184208type Unrolled t = Reverse (IfStuckUnroll (UnrollIsStuckError t ) (Unroll t ))
0 commit comments