[Haskell-cafe] [template haskell] Sharing names between constructors and types
Patrick L Redmond
plredmond at ucsc.edu
Thu May 19 20:15:23 UTC 2022
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
More information about the Haskell-Cafe
mailing list