[C2hs] Default Marshallers / Arbitrary expressions as marshallers

Benedikt Huber benjovi at gmx.net
Fri Aug 22 13:39:42 EDT 2008


Hi again,

I noted Gour filed a ticket for 'allowing arbitrary expressions as  
marshallers'.

 > http://hackage.haskell.org/trac/c2hs/ticket/13

This sounds interesting, but I wonder which would be the most sensible  
implementation strategy.
Do you suggest to implement hs98 expressions using the existing  
framework ? Is there some existing code that could be reused ?

Apart from that, I think the following additional default marshallers  
would make sense:

a) If the hs type is defined in an {# enum ... #} hook and the C type  
is integral, use (fromEnum/toEnum . cIntConv) as default.

b) If the hs type and C type match, and are of the form (Ptr a), use  
'id' as default. This is really useful when working with opaque  
pointers, but maybe there are type-safety related reasons why this  
shouldn't be done.

c) Additionally, we could allow the user to add other default  
marshallers, depending on the combination of hs/C type. If I recall  
correctly, Duncan had some ideas for this one ?

best regards,
benedikt


More information about the C2hs mailing list