On 29 May 2008, at 11:46 PM, Galchin, Vasili wrote:
Hello,
I don't want to write kludgy Haskell code!
typedef struct blah
{
int val1;
union {
int val2;
struct {
int val3;
int val4;
}
}
} C_type;
question: in Haskell, can I embed definition of the "union" inside
of the C typedef, i.e. recursion definition? Or must I have a
separate definition for the "union" which I "instantiate" inside
the Haskell "typedef", i.e. Haskell "data"?
Assuming all of these are semantic, you can say
newtype HS_type = HS_type (Int, Either Int (Int, Int))
But you lose named fields.
It's hard to give other advice without some idea of /why/ you want to
do something like this.
jcc
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe