On Mar 22, 2013 2:58 AM, C K Kashyap ckkash...@gmail.com wrote:
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
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,
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
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
x = C3 (C1 10) -- should not compile - but my above definition will let it
compile
I was
You could use a GADT:
{-# LANGUAGE GADTs #-}
data T a where
C1 :: Int - T Int
C2 :: Char - T Char
C3 :: T Char - T Char
This will allow you to put a C3 in a C3. If you want to prevent that,
just invent some other index, something like:
{-# LANGUAGE GADTs, EmptyDataDecls #-}
data Yes
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