@@ -402,7 +402,7 @@ deriveSerializeWith conf mDecs = do
402 dec <- mDecs
402 dec <- mDecs
403 case dec of
403 case dec of
404 [inst@(InstanceD _ _ headTy [])] -> do
404 [inst@(InstanceD _ _ headTy [])] -> do
405− dt <- reifyDataType (getMainTypeName headTy)
405+ dt <- reifyDataType (getMainTypeName dec headTy)
406 let cons = dtCons dt
406 let cons = dtCons dt
407 deriveSerializeInternal conf headTy cons (next inst)
407 deriveSerializeInternal conf headTy cons (next inst)
408 _ -> errorUnsupported
408 _ -> errorUnsupported
@@ -412,14 +412,31 @@ deriveSerializeWith conf mDecs = do
412 pure [InstanceD mo preds headTy methods]
412 pure [InstanceD mo preds headTy methods]
413 next _ _ = errorUnsupported
413 next _ _ = errorUnsupported
417+ [ "Error: deriveSerializeWith:"
419+ , ">> " ++ pprint dec
421+ , "The above is not a valid instance declaration."
422+ , "Any haskell instance declaration without a body is valid."
425+ , "instance Serialize (Proxy a)"
426+ , "instance Serialize a => Serialize (Identity a)"
427+ , "instance Serialize (TableT Identity)"
415− getMainTypeName = go . unwrap
430+ getMainTypeName dec = go . unwrap
417− unwrap (AppT (ConT _) r) = r
434+ unwrap (AppT (ConT _) r) = r
418− unwrap _ = error "getMainTypeName.unwrap: Undefined instance declaration."
435+ unwrap _ = errorMessage dec
420− go (ConT nm) = nm
437+ go (ConT nm) = nm
421− go (AppT l _) = go l
438+ go (AppT l _) = go l
422− go _ = error "getMainTypeName.go: Undefined instance declaration."
439+ go _ = errorMessage dec
425-- | Template haskell helper to create instances of 'Serialize' automatically.
442-- | Template haskell helper to create instances of 'Serialize' automatically.