On Oct 1, 2009, at 19:22 , Gregory Propf wrote:
Is there a way to tell, let's say, how many constructors there are for a type? Or do I need one of the haskell extensions I've read about?


If the constructors are nullary (that is: data MyData = Foo | Bar | Baz) you could derive Enum and Bounded, then (maxBound :: MyData) is one less than the number of constructors.

Anything more complicated requires deriving Data or Typeable (I've done it with the latter but don't recall details off the top of my head).

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university    KF8NH


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to