Say I have something like
data DT a = Foo a | Bar a | Boo a
I want something like a list of the constructors of DT, perhaps as [TypeRep].
I'm using Data.Typeable but can't seem to find what I need in there.
Everything there operates over constructors, not types.
Gregory Propf wrote:
Say I have something like
data DT a = Foo a | Bar a | Boo a
I want something like a list of the constructors of DT, perhaps as [TypeRep].
I'm using Data.Typeable but can't seem to find what I need in there.
Everything there operates over constructors, not types.
The
I've put some of Oleg's code on hackage, named polytypeable.
import Data.PolyTypeable
main = print [polyTypeOf Nothing, polyTypeOf Just]
This prints
[Maybe a1,a1 - Maybe a1]
To get a list of the actual constructors you need to derive
Data.Data.Data and use that.
-- Lennart
On Wed, Dec