
Hello ALL, I am very new to Haskell and my question might appear very basic sorry about it in advance. I have a C++ application and I would like to be able to launch Haskell interpreter (lets say GHC) supplying the Haskell code (in a file ) to be interpreted from it. The Haskell program generates some output and I would like to use this output in my C++ program. Do you have any simple example to help me, please? Many thanks, Vladimir _________________________________________________________________ Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://join.msn.com/messenger/overview

"Vladimir" == Vladimir Portnykh
writes:
Vladimir> Hello ALL, I am very new to Haskell and my question might Vladimir> appear very basic sorry about it in advance. I have a C++ Vladimir> application and I would like to be able to launch Haskell Vladimir> interpreter (lets say GHC) supplying the Haskell code (in a ghci - not ghc. Vladimir> file ) to be interpreted from it. The Haskell program Vladimir> generates some output and I would like to use this output in Vladimir> my C++ program. Do you have any simple example to help me, Vladimir> please? Hmm. That depends on what the output of the haskell program is. If I understand you corrrectly the output of the program is what it writes to the stdout. In this case you'll can do the job using popen(2) (or whatever is available in your OS) - you create process to run 'runhaskell file.hs' and redirect its stdout to a pipe. There is also an FFI which allows you to call functions written in Haskell from other languages. In this case your Haskell program must export C-level API to be used from C++. Or, and of cause you can use IPC to connect your programs. -- WBR, Max Vasin. NP:

On Tue, May 23, 2006 at 10:31:17AM +0100, Vladimir Portnykh wrote:
Hello ALL, I am very new to Haskell and my question might appear very basic sorry about it in advance. I have a C++ application and I would like to be able to launch Haskell interpreter (lets say GHC) supplying the Haskell code (in a file ) to be interpreted from it. The Haskell program generates some output and I would like to use this output in my C++ program. Do you have any simple example to help me, please? Many thanks, Vladimir
You might also try compiling / using hsplugins, which compiles haskell code at runtime.. There is an example how to compile/call such a haskell method from C. Marc

On 5/23/06, Marc Weber
On Tue, May 23, 2006 at 10:31:17AM +0100, Vladimir Portnykh wrote:
Hello ALL, I am very new to Haskell and my question might appear very basic sorry about it in advance. I have a C++ application and I would like to be able to launch Haskell interpreter (lets say GHC) supplying the Haskell code (in a file ) to be interpreted from it. The Haskell program generates some output and I would like to use this output in my C++ program. Do you have any simple example to help me, please? Many thanks, Vladimir
You might also try compiling / using hsplugins, which compiles haskell code at runtime.. There is an example how to compile/call such a haskell method from C.
Hs-plugins just calls GHC. Going through Haskell to execute GHC is overkill in the extremes. -- Friendly, Lemmih
participants (4)
-
Lemmih
-
Marc Weber
-
Max Vasin
-
Vladimir Portnykh