
A `NameG`, the constructor of `Name` that your name probably has, has a `NameSpace` field that indicates in what namespace the name lives. See the documentation: https://hackage.haskell.org/package/template-haskell-2.18.0.0/docs/Language-... If you have the name of a type (with namespace `TcClsName`) and want to use it as a data constructor (which normally has namespace `DataName`), you probably need to change the namespace. - Tom On 20/05/2022 00:11, Patrick L Redmond via Haskell-Cafe wrote:
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
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
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.