[Haskell-iPhone] FFI for living in C
Robert Lorentz
robert.lorentz at me.com
Sun Dec 2 02:20:18 CET 2012
Getting the TH/Objective Haskell layer going will be GLORIOUS if it can achieve easier integration
On Dec 1, 2012, at 6:43 PM, Luke Iannini <lukexipd at gmail.com> wrote:
> Hi guys,
>
> It's also possible to start the Haskell runtime from within C/C++,
> using the hs_init() and hs_exit() functions (you can just call them
> each one at startup and shutdown before calling into any Haskell code
> that's been "foreign export"ed), to skip the c_main business.
>
> See 8.2.1.1 here:
> http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/ffi-ghc.html
>
> There's a great chapter in Real World Haskell on exporting and
> importing functions to call to and from C/C++:
> http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html
>
> For Objective-C, Objective Haskell is an even higher level (and quite
> excellent) project for calling to and from Obj-C and converting its
> standard data types (NSDictionaries, NSStrings, NSData etc.) into
> Haskell's (Maps, Text, ByteStrings etc.), and vice-versa.
> https://github.com/jspahrsummers/ObjectiveHaskell
>
> It uses Template Haskell to make importing and exporting extremely
> easy and clean, but sadly ghc-ios doesn't support TH quite yet. I have
> an experimental branch that replaces the TH with manually-written
> boilerplate but of course it's a lot messier. I'll be publishing it
> soon anyway : ).
>
> Cheers
> Luke
>
> On Sat, Dec 1, 2012 at 1:26 PM, Stephen Paul Weber
> <singpolyma at singpolyma.net> wrote:
>> Somebody claiming to be Casey Basichis wrote:
>>>
>>> Is the FFI the right tool for a situation where, while used extensively,
>>> Haskell is more or less there to take in data, like lists and spit out
>>> data
>>> like vectors etc back to C.
>>
>>
>> My current favourite way to do this is to start in Haskell-land and call
>> some entry-point function in extern "C" that takes function pointers as
>> arguments. These function pointers become the way that C++ code can call
>> back into Haskell-land.
>>
>> This is what I am using for <http://github.com/singpolyma/haskades>
>>
>> --
>> Stephen Paul Weber, @singpolyma
>> See <http://singpolyma.net> for how I prefer to be contacted
>> edition right joseph
>>
>>
>> _______________________________________________
>> iPhone mailing list
>> iPhone at haskell.org
>> http://www.haskell.org/mailman/listinfo/iphone
>
> _______________________________________________
> iPhone mailing list
> iPhone at haskell.org
> http://www.haskell.org/mailman/listinfo/iphone
More information about the iPhone
mailing list