Hi Alberto,<br>thanks for the hint and the link. Do you have any information on whether that will continue to work in the future? I somehow have a bad feeling about it because the C* versions of the types would then be unnecessary.<br><br>Thanks again,<br>Christian<br><br>----- Reply message -----<br>Von: &quot;Alberto Ruiz&quot; &lt;aruiz@um.es&gt;<br>An: &quot;C Gosch&quot; &lt;ch.gosch@googlemail.com&gt;<br>Cc: &lt;beginners@haskell.org&gt;<br>Betreff: [Haskell-beginners] Question about CFloat and Float<br>Datum: Do., Apr. 28, 2011 15:27<br><br><br>Hi Christian,<br><br>On 04/28/2011 02:27 PM, C Gosch wrote:<br>&gt; Dear list members,<br>&gt; I have the following problem: I have wrapped a C library using the FFI<br>&gt; and c2hs.<br>&gt; The C functions all take a bunch of pointers to C arrays of floats,<br>&gt; doubles, or ints as arguments.<br>&gt; Naturally, the Haskell representation of these is e.g.<br>&gt; &nbsp; Ptr CFloat<br>&gt; or, for single values, CFloat.<br>&gt; My question is: if I have an array, e.g. allocated with mallocArray, to<br>&gt; Haskell Float values (Ptr Float),<br>&gt; is the representation of Float exactly the same as for CFloat? Can I<br>&gt; safely use Ptr Float where the C function<br>&gt; expects the C type float* ?<br>&gt; I assume that I can not, and in that case I would like to find a way to<br>&gt; have Float on the Haskell side and CFloat on the C side.<br>&gt; Any hint on how I would do that without copying data and without too<br>&gt; large performance penalties?<br>&gt;<br>&gt; Thanks a lot,<br>&gt; Christian<br>&gt;<br><br>I think that in ghc you can assume the same representation for CFloat <br>and CDouble, they are newtypes of Float and Double:<br><br>http://www.haskell.org/ghc/docs/7.0.3/html/libraries/base-4.3.1.0/Foreign-C-Types.html#g:4<br><br>(I directly use arrays of Float and Double with C libraries without any <br>problem). But Int may be different from CInt depending on the <br>architecture, so we need explicit conversions.<br><br>Alberto<br>