conNameOf
allows me to display the constructor name of a given piece of data, given that type is an instance of Generic
.
What I'd like is something similar. For a given type, I want to get the full list of constructor names. For example:
data Nat = Z | S Nat
deriving (Generic)
-- constrNames (Proxy :: Proxy Nat) == ["Z", "S"]
Does something like constrNames
exist? If not, how can I write it?
Aucun commentaire:
Enregistrer un commentaire