I think you should definitely use hsc2hs.<br>It is simple to you use and would allow you to replace things like:<br><pre style="font-family: courier new,monospace;" class="source-haskell">peek ptr <span class="sy0">=</span> <span class="kw1">do</span>
<b>    a <span class="sy0">&lt;-</span> peekByteOff ptr <span class="nu0">0</span>
    b <span class="sy0">&lt;-</span> peekByteOff ptr <span class="nu0">4</span></b>
    <span class="kw3">return</span> <span class="br0">(</span>MyStructType a b<span class="br0">)<br><br>By:<br><br>#include &quot;MyStruct.h&quot;<br>-- ^ Needs to be defined in a separate header<br><br>peek ptr = do<br>

    a &lt;- (#peek MyStruct, foo) ptr<br>    b &lt;- (#peek MyStruct, bar) ptr<br>    return (MyStructType a b)<br></span></pre>But I just know hsc2hs. Does c2hs automatically writes the Storable instances ? (Because it&#39;s kind of a daunting task...)<br>

<br><br><div class="gmail_quote">2011/4/12 Andrew Pennebaker <span dir="ltr">&lt;<a href="mailto:andrew.pennebaker@gmail.com">andrew.pennebaker@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

hsc2hs and c2hs are good suggestions, and some of the tutorials I&#39;m following use them.<div><br></div><div>But 1) Many Haskell FFI tutorials don&#39;t require them, so they only seem to help, or only help in older versions of GHC.</div>



<div><br></div><div>And 2) When I did compile using c2hs, it just produced the same file, but with filler comments like {#- LINE 13 #-}. And they still refused to compile for the same reason:</div><div><br></div><div><div class="im">

ld: duplicate symbol _Charm_getWidth_info in charm.o and charm.o<br clear="all">

<div><br></div></div><div class="im">Cheers,<div><br></div><div>Andrew Pennebaker</div><div><a href="http://www.yellosoft.us" target="_blank">www.yellosoft.us</a></div>
<br></div><div><div></div><div class="h5"><div class="gmail_quote">On Sat, Apr 9, 2011 at 9:50 PM, Jason Dagit <span dir="ltr">&lt;<a href="mailto:dagitj@gmail.com" target="_blank">dagitj@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<p>I don&#39;t know how to make ghc load them without using either hsc2hs or c2hs. I&#39;ve had better experiences with hsc, but your mileage may vary.</p>
<p></p><blockquote type="cite"><div><div></div><div>On Apr 8, 2011 3:34 AM, &quot;Andrew Pennebaker&quot; &lt;<a href="mailto:andrew.pennebaker@gmail.com" target="_blank">andrew.pennebaker@gmail.com</a>&gt; wrote:<br>

<br>ncurses is proving too difficult to setup, so I&#39;m working on a new library called charm. The C code works by itself, but I can&#39;t compile a Haskell wrapper for it. While the tutorials at <a href="http://www.haskell.org/haskellwiki/FFI_complete_examples" target="_blank">HaskellWiki</a> are helpful, they&#39;re outdated. Argh! The <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#glasgow-foreign-headers" target="_blank">docs</a> say that -#include pragmas no longer work, but fail to explain how to load code without them. Suffice to say I have no recourse but trial and error.<br>






<br>GitHub: <a href="https://github.com/mcandre/charm" target="_blank">charm</a> and <a href="https://github.com/mcandre/hscharm" target="_blank">hscharm</a><br><br><a href="https://github.com/mcandre/charm" target="_blank"></a>$ make<br>




cp /usr/include/charm.c .<br>ghc --make -fforce-recomp -o hellocharm hellocharm.hs charm.hs charm.c -I/usr/include -dylib-install-name /usr/lib/libcharm.dynlib<br>

[1 of 2] Compiling Charm            ( charm.hs, charm.o )<br>[2 of 2] Compiling Main             ( hellocharm.hs, hellocharm.o )<br>Linking hellocharm ...<br>ld: duplicate symbol _Charm_getWidth_info in charm.o and charm.o<br>






collect2: ld returned 1 exit status<br>make: *** [hellocharm] Error 1<br clear="all"><div><br></div>Cheers,<div><br></div><font color="#888888"><div>Andrew Pennebaker</div><div><a href="http://www.yellosoft.us" target="_blank">www.yellosoft.us</a></div>







</font><br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote><p></p>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>