<div dir="ltr">The simplest way generally is to make make a C binding and then bind Haskell from there. You may indeed want to take a look at wxWidgets' binding or SFML's (<a href="https://github.com/jeannekamikaze/SFML">https://github.com/jeannekamikaze/SFML</a>).</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 18, 2013 at 1:05 AM, kudah <span dir="ltr"><<a href="mailto:kudahkukarek@gmail.com" target="_blank">kudahkukarek@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'd suggest to first look at how other C++-bindings for haskell are<br>
implemented. e.g. wxHaskell is the most mature Haskell C++ binding out<br>
there. hogre tries to generate bindings from headers. And a number of<br>
(rather minimal) bindings to some libs were made as part of Nikki and<br>
the Robots.<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, 17 Jan 2013 18:48:02 +0100 Nathan Hüsken<br>
<<a href="mailto:nathan.huesken@posteo.de">nathan.huesken@posteo.de</a>> wrote:<br>
<br>
> Hey,<br>
><br>
> I would like to write FII bindings in haskell for cocos2d-x<br>
> (<a href="http://www.cocos2d-x.org/" target="_blank">http://www.cocos2d-x.org/</a>), which is a C++ library.<br>
><br>
> Since I have little experience with this, I would like some feedback<br>
> before I discover that concept is bad half way.<br>
><br>
> In cocos2d there is a base class with much functionality: CCNode<br>
> Many classes derive from it (i.E. CCLayer) and use the virtual<br>
> functions of CCNode (i.E. setPosition).<br>
><br>
> How do I map this to haskell?<br>
><br>
> The general Idea:<br>
><br>
> I have a typeclass, in which everything that is derived from CCNode is<br>
> an instance:<br>
><br>
> class NodeDerived a where<br>
> toNode :: a -> Node<br>
><br>
> setPosition :: a -> (Double,Double) -> IO ()<br>
> setPosition a pos = setNodePosition (toNode a) pos<br>
><br>
> instane NodeDerived Layer where<br>
> toNode = layerToNode<br>
><br>
> and layerToNode :: Layer -> Node would be implemented in C++ as:<br>
><br>
> CCNode* layerToNode(CCLayer* l) { return<br>
> dynamic_cast<CCNode*>(l); }<br>
><br>
> This way I would have only to implement toNode for every class derived<br>
> from CCNode and get all the functions CCNode defines.<br>
><br>
> What do you think if this Idea?<br>
> How would you do it?<br>
><br>
> Thanks!<br>
> Nathan<br>
><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>
_______________________________________________<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>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Alp Mestanogullari
</div>