[Haskell-beginners] Haskell-style types in C or C++

Michael Xavier nemesisdesign at gmail.com
Sat Jul 30 21:51:13 CEST 2011


You should look into the Union datatype. It has been a long while since I
coded in C but I believe it allowed you to define a struct-like datatype
which could contain exactly 1 value from a list of datatypes. I found a
forum post about it:

http://www.go4expert.com/forums/showthread.php?t=15

Hope that helps.

On Sat, Jul 30, 2011 at 11:45 AM, Christopher Howard <
christopher.howard at frigidcode.com> wrote:

> One of the things that I love about Haskell is the syntax for creating user
> defined types. E.g.:
>
> Data QueryResult = NoResult | DatabaseError String | Results [String]
>
> I can prototype an entire program around these self-made types and it is a
> lot of fun. Out of intellect curiosity, though: what would be the equivalent
> construction in C or C++? (Say, for the type defined above).
>
> --
> frigidcode.com
> theologia.indicium.us
>
> ______________________________**_________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>



-- 
Michael Xavier
http://www.michaelxavier.net
LinkedIn <http://www.linkedin.com/pub/michael-xavier/13/b02/a26>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110730/8873357e/attachment.htm>


More information about the Beginners mailing list