[Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

Yves Parès yves.pares at gmail.com
Mon Jan 23 00:44:37 CET 2012


I may be curious to see how you intend to use such enum...
It is very C-wise, I'm not sure it will be very handy, but I need some
context.

2012/1/22 Данило Глинський <abcz2.uprola at gmail.com>

> What is natural Haskell representation of such enum?
>
> enum TypeMask
> {
>    UNIT,
>    GAMEOBJECT,
>
>    CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT
> };
>
> More sophisticated question is: and what data structures must be used when
> converting this naturally one to Haskell?
>
> // 1-byte flaged enum
> enum TypeMask
> {
>    // ...
>    UNIT        = 0x0004,
>    GAMEOBJECT  = 0x0008,
>    // ...
>
>    CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT
> WORLDOBJECT = UNIT | PLAYER | GAMEOBJECT | DYNAMICOBJECT | CORPSE
>    // ... even more enum combos ...
> };
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120123/82438d76/attachment-0001.htm>


More information about the Haskell-Cafe mailing list