I worked around the issue. Apologies for the noise. I'm still learning, but I think the reason for this error is: * The name passed to `voidType` contains module information, and possibly other information. * By reusing the name in the output of `voidType` (as a type) we are incorrectly overriding the existing name (of a constructor), even though they're ostensibly different namespaces. A workaround is to perform `mkName $ nameBase n` inside `voidType`. On Thu, May 19, 2022 at 1:15 PM Patrick L Redmond <plredmond@ucsc.edu> wrote:
Hello Haskell Cafe,
When can a type not share the name of a constructor?
Defining a type and a constructor with the same name, manually, as follows, seems to be acceptable:
data F = F | T data T
However, if the type is generated by Template Haskell, it is no longer acceptable, as follows:
voidType :: Name -> DecsQ voidType n = do d <- dataD (return []) n [] Nothing [] [] return [d]
In a separate module:
data F = F | T $(voidType 'T)
This will result in a "Multiple declarations of âTâ" error. Is this expected?
Thank you, Patrick