declaring C enum types

Manuel M T Chakravarty chak at
Thu Oct 17 04:18:45 EDT 2002

Antony Courtney <antony at> wrote,

> A relatively mundane question:
> Is there a preferred means of writing a foreign import declaration for a 
> C function with a prototype that takes an "enum" argument?
> i.e., in C we have:
> enum bar {
>    GOOD,  BAD
> };
> void foo(enum bar x);

That's exactly the kind of scenario for which I have written

Using C->Haskell, you write into the binding module

  {#enum bar as Bar#}

run it through the tool and get a Haskell data definition
for `Bar', so that you can safely marshal between C's bar
and Haskell's Bar.  (See also the corresponding section in
the manual


More information about the FFI mailing list