Confused by FFI
Ian Lynagh
igloo at earth.li
Mon Jul 8 18:10:57 EDT 2002
On Mon, Jul 08, 2002 at 10:19:20PM +0100, Alastair Reid wrote:
>
> >> For what it's worth, I ran Ian's program on Hugs (with minor
> >> changes: Hugs gets confused by the use of type synonyms in ffi
> >> decls)
>
> > Is this a hugs bug or am I being non-portable?
>
> I'd class it as a reflection of the immaturity of Hugs' new ffi
> implementation - but others might reasonably call it a Hugs bug :-)
Sorry if my language was too strong, I just wanted to check I was
working within the FFI spec.
> For them that care, the problems in Hugs are:
[snip]
Thanks.
> > I reached this point having discovered that the Haskell equivalent
> > of "keypad(stdscr, TRUE)" (insert digression/rant about having to
> > assume bool is a numerical type in curses here) had no effect but
> > using the result of initscr worked fine.
>
> I presume the rant would be to the effect that it's painful that the
> ffi doesn't handle macros such as TRUE or perhaps the plausible but not
> always correct use of 0/1 to marshall False/True?
It was more directed at the lack of assumptions curses allows you to
make than the Haskell side, but even so the answer is "not really".
> The short answer is that GreenCard and friends exist for that very
> purpose.
I'm currently using hsc2hs and have code like this:
type NBool = #type bool
cTRUE :: NBool
cTRUE = #const TRUE
The problem comes when bool is, say, a 72bit structure and #type can't
provide a suitable Haskell type.
I'm happy to be corrected on this, particularly if it makes my life
easier :-)
I'll have a better look at GreenCard (I think I decided it was more
complex than hsc2hs for what I was doing at the time, but I might need
the extra complexity now) some time and see if it can help me out.
Thanks
Ian
More information about the Glasgow-haskell-bugs
mailing list