
readConstr [1] from Data.Data will do the trick. DataType for a type can be retrieved with dataTypeOf. ---- 1: https://hackage.haskell.org/package/base-4.8.0.0/docs/Data-Data.html#v:readC... On 5/19/2015 1:20 AM, Cody Goodman wrote:
Can I use either template Haskell, GHC Generics, or something else to get the list of Constructors in Codes? Then I could do `map show codeSumTypeMembers` and get `["A0100A","A0500A"]`?
Here's an example of solving this problem manually:
data Codes = A0100A | A0500A deriving Show
codeExists "A0100A" = True codeExists "A0500A" = True codeExists _ = False
main = print $ codeExists xmlElementName where xmlElementName = "A0500A"
-- λ> main -- True _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe