[Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread David Fox
Is it possible to determine the arity of a value's constructor? Suppose I have a value x of type data A = B Int | C They typeOf function returns its TypeRep, which contains its type constructor, but I don't see how to decide whether that constructor's arity is 0 or 1. If the type has field

Re: [Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread José Pedro Magalhães
Hey David, For instance: arity :: (Data a) = a - Int arity = length . gmapQ (const ()) Cheers, Pedro On Thu, Jun 25, 2009 at 17:31, David Fox dds...@gmail.com wrote: Is it possible to determine the arity of a value's constructor? Suppose I have a value x of type data A = B Int | C

Re: [Haskell-cafe] Can you determine a constructor's arity using Data.Typeable and Data.Data?

2009-06-25 Thread David Fox
Oh, that make sense! 2009/6/25 José Pedro Magalhães j...@cs.uu.nl Hey David, For instance: arity :: (Data a) = a - Int arity = length . gmapQ (const ()) Cheers, Pedro On Thu, Jun 25, 2009 at 17:31, David Fox dds...@gmail.com wrote: Is it possible to determine the arity of a