[C2hs] Matching defined types (lookupDftMarshIn "CH" [DefinedET gcry_cipher_hd_t h; "CH"])

Manuel M T Chakravarty chak at cse.unsw.edu.au
Tue Sep 12 22:26:02 EDT 2006


Einar,

> I have a library that defines handles which are pointers
> as something like
> typedef void* ch_t;
> 
> Wrapping with C2HS I can do:
> {#pointer ch_t as CH #}
> 
> But when I try to use it like:
> {#fun ch_close {`CH'} -> `()' #}
> 
> C2HS complains:
>   >>> Missing "in" marshaller!
>   There is no default marshaller for this combination of Haskell and C type:
>   Haskell type: CH
>   C type      : (CH)
> 
> When looking at the internals it comes to a call like:
> lookupDftMarshIn "CH" [DefinedET ch_t h; "CH"]
> 
> Why don't they match and what should be changed to make things work?

Default marshaller don't know anything about the type names introduced
by pointer hooks.  However, it would be great if this would work.  (I
actually thought about it, but never got around to implementing it.)

At the moment, the matching happens in two purely statically defined
functions: GenBind.lookupDftMarshIn and GenBind.lookupDftMarshOut.
There is actually a FIXME in the comment preceding the functions
suggesting something more dynamic.  If you would be willing to extend
the implementation along the lines of this comment, that would be
terrific!

If you have any problems/questions about how to do it, I'd be happy to
assist.  (But I'll be away for nearly two weeks from Saturday - due to
ICFP.  I guess, I will have email there, but maybe not very much time to
answer.)

Manuel




More information about the C2hs mailing list