Hi, I've been reading about the FFI for getting Haskell to communicate with C code (C++ really). My intention is to handle most of the app - the GUI events in C++ and sending all of the processing logic in Haskell - including a database etc. 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. I am looking to get a few test running where I can pass data in an out of Haskell like vectors of floats. Also, I noticed on the wiki example: Haskell start c_main I was a little confused by this. Does Haskell load up first because its a library? I couldn't figure out where it was being called in the C code or why Haskell loads first. Not a biggie just a bit of an impediment in understanding how it all works. Thanks, Casey -- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis@gmail.com 310.387.7540
Casey -
Yep your use case is a good one. It's my approach too and this set up should achieve it
The confusion about which loads up first --
The Haskell .a must have a main(). So it must be the entry point. So it must start first. It then launches the objc's "c_main" so that normal control/flow can occur.
Then you simply call your Haskell code whenever you want and essentially you can just sleep the haskell's main forever
Hope this helps -- don't think I'm an expert, I just happen to have the identical questions as you and I started 2 days before you :)
On Dec 1, 2012, at 12:28 PM, Casey Basichis
Hi,
I've been reading about the FFI for getting Haskell to communicate with C code (C++ really).
My intention is to handle most of the app - the GUI events in C++ and sending all of the processing logic in Haskell - including a database etc.
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.
I am looking to get a few test running where I can pass data in an out of Haskell like vectors of floats.
Also, I noticed on the wiki example:
Haskell start c_main I was a little confused by this. Does Haskell load up first because its a library? I couldn't figure out where it was being called in the C code or why Haskell loads first. Not a biggie just a bit of an impediment in understanding how it all works.
Thanks, Casey
-- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis@gmail.com 310.387.7540 _______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
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
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
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@haskell.org http://www.haskell.org/mailman/listinfo/iphone
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
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
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@haskell.org http://www.haskell.org/mailman/listinfo/iphone
_______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
FWIW, I put together this project a while back:
https://github.com/dpp/LispHaskellIPad It's some calls between GHC and iOS.
There's also https://github.com/visi-lang/visi which has some iOS
interactions with Haskell
On Sat, Dec 1, 2012 at 3:43 PM, Luke Iannini
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
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@haskell.org http://www.haskell.org/mailman/listinfo/iphone
_______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
-- Telegram, Simply Beautiful CMS https://telegr.am Lift, the simply functional web framework http://liftweb.net Follow me: http://twitter.com/dpp Blog: http://goodstuff.im
Thanks for all the information, those should help zero in on a workflow.
I'm going to dive into those on tuesday after I hit a deadline. I have a
week coming to roll in the blissful meadows of Haskell.
On Sat, Dec 1, 2012 at 8:39 PM, David Pollak
FWIW, I put together this project a while back: https://github.com/dpp/LispHaskellIPad It's some calls between GHC and iOS.
There's also https://github.com/visi-lang/visi which has some iOS interactions with Haskell
On Sat, Dec 1, 2012 at 3:43 PM, Luke Iannini
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
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@haskell.org http://www.haskell.org/mailman/listinfo/iphone
_______________________________________________ iPhone mailing list iPhone@haskell.org http://www.haskell.org/mailman/listinfo/iphone
-- Telegram, Simply Beautiful CMS https://telegr.am Lift, the simply functional web framework http://liftweb.net Follow me: http://twitter.com/dpp Blog: http://goodstuff.im
-- Casey James Basichis Composer - Cartoon Network http://www.caseyjamesbasichis.com caseybasichis@gmail.com 310.387.7540
participants (5)
-
Casey Basichis -
David Pollak -
Luke Iannini -
Robert Lorentz -
Stephen Paul Weber