Thanks Eric and Brent, Even with GADT, it appears that I'd need extra data definitions. I'll go without GADT then ... Brent, my use case is not particularly complicated. I am trying to model the pdf spec - which says that pdf contains Objects that could of of types Number, String, Name, Array and Dictionary - while array is list of objects, the Disctionary is a list of tuples (Name, Object) not (Object, Object) - hence my situation. Regards, Kashyap On Thu, Mar 21, 2013 at 8:58 PM, Brent Yorgey <byorgey@seas.upenn.edu>wrote:
On Thu, Mar 21, 2013 at 06:18:46PM +0530, C K Kashyap wrote:
Hi,
I have a situation where I need to define a data type T such that
data T = C1 Int | C2 Char | C3 T
However, I want to enforce a constraint that C3 only allows (C2 Char) and not (C1 Int). That is
If C3 should only be able to hold a C2 Char, then why have it hold a T at all? i.e. why not
data T = C1 Int | C2 Char | C3 Char
but I suppose your real problem is probably more complicated, in which case I would recommend using a GADT as others have suggested.
-Brent
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe