[Haskell-cafe] Read instance for constructors?
Niklas Haas
haskell at nand.wakku.to
Mon Mar 10 13:59:36 UTC 2014
On Mon, 10 Mar 2014 14:54:14 +0100, Niklas Haas <haskell at nand.wakku.to> wrote:
> You can derive Data using the DeriveDataTypeable extension and then use
> the toConstr :: Data a => a -> Constr method to obtain the Constr (which
> has a Show instance that in this case just returns "A", "B" etc.)
Oops, you are asking about the other direction. Well, you're in luck
here too - Data has readConstr :: DataType -> String -> Maybe Constr.
More information about the Haskell-Cafe
mailing list