Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-14 Thread Colin Paul Adams
 Colin == Colin Paul Adams [EMAIL PROTECTED] writes:

Colin And thanks everyone for your help. I have enough to go on
Colin now.

I followed the example at
http://www.haskell.org/haskellwiki/Calling_Haskell_from_C

(and renamed the files from A* to fib1*, as I want to pursue this
further).

But I get:

fib1.o: In function `main':
fib1.c:(.text+0x0): multiple definition of `main'
fib1.o:fib1.c:(.text+0x0): first defined here
fib1_stub.o: In function `stginit_export_Safe_zdffibonaccizuhszuaDN':
fib1_stub.c:(.text+0x5): undefined reference to 
`Safe_zdffibonaccizuhszuaDN_closure'
fib1_stub.o: In function `fibonacci_hs':
fib1_stub.c:(.text+0x32): undefined reference to 
`Safe_zdffibonaccizuhszuaDN_closure'
collect2: ld returned 1 exit status

-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-14 Thread Don Stewart
colin:
  Colin == Colin Paul Adams [EMAIL PROTECTED] writes:
 
 Colin And thanks everyone for your help. I have enough to go on
 Colin now.
 
 I followed the example at
 http://www.haskell.org/haskellwiki/Calling_Haskell_from_C
 
 (and renamed the files from A* to fib1*, as I want to pursue this
 further).
 
 But I get:
 
 fib1.o: In function `main':
 fib1.c:(.text+0x0): multiple definition of `main'
 fib1.o:fib1.c:(.text+0x0): first defined here
 fib1_stub.o: In function `stginit_export_Safe_zdffibonaccizuhszuaDN':
 fib1_stub.c:(.text+0x5): undefined reference to 
 `Safe_zdffibonaccizuhszuaDN_closure'
 fib1_stub.o: In function `fibonacci_hs':
 fib1_stub.c:(.text+0x32): undefined reference to 
 `Safe_zdffibonaccizuhszuaDN_closure'
 collect2: ld returned 1 exit status

Not linking in the 'Safe' module on the command line?

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-14 Thread Colin Paul Adams
 Don == Don Stewart [EMAIL PROTECTED] writes:

Don Not linking in the 'Safe' module on the command line?

Could be - I don't know any of this stuff. I was just following the
instructions on the wiki page.

How should these be amended?
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-14 Thread Colin Paul Adams
 Colin == Colin Paul Adams [EMAIL PROTECTED] writes:

 Don == Don Stewart [EMAIL PROTECTED] writes:
Don Not linking in the 'Safe' module on the command line?

Colin Could be - I don't know any of this stuff. I was just
Colin following the instructions on the wiki page.

Got it working now. It seemed to be some case dependency on the file name.
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-12 Thread Dave Tapley
Hi Colin

As an alternative you may consider using Thrift:
http://incubator.apache.org/thrift/

Cheers,
Dave


On Tue, 2008-11-11 at 16:45 +, Colin Paul Adams wrote:
 Is there a way to call Haskell code from other languages? I have looked on
 the wiki, and as far as I can see, it only talks about the other way
 round (when Haskell is the main program).

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Jake Mcarthur

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Nov 11, 2008, at 10:45 AM, Colin Paul Adams wrote:

Is there a way to call Haskell code from other languages? I have  
looked on

the wiki, and as far as I can see, it only talks about the other way
round (when Haskell is the main program).


http://www.haskell.org/haskellwiki/GHC/Using_the_FFI#Calling_Haskell_from_C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkkZuCkACgkQye5hVyvIUKk1pwCfRbVnERADZPygCNX2wjNkdQOC
FXMAoKodV1TitVzr5ZJF/AUSmCXuRuKY
=BUkK
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Donn Cave
Quoth Colin Paul Adams [EMAIL PROTECTED]:

| Is there a way to call Haskell code from other languages? I have looked on
| the wiki, and as far as I can see, it only talks about the other way
| round (when Haskell is the main program).

There sure is a way to call from other languages - cf. foreign export -
but don't know how hard it would be to make Haskell live without its main,
which performs a lot of runtime initialization.

For me (with nhc98) it's a lot easier to use a Haskell main that's just
a brief wrapper:

  module Main (main) where
  import NHC.FFI

  foreign import ccall cmain cmain :: IO ()

  main = cmain

(... where cmain is an external entry point in the C code, which can
then call Haskell as required.)

Donn
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Derek Elkins
On Tue, 2008-11-11 at 17:09 +, Colin Paul Adams wrote:
  Jake == Jake Mcarthur [EMAIL PROTECTED] writes:
 
 Jake Actually, that's not the whole story. I didn't realize until
 Jake I sent it. There does exist good documentation for this, I
 Jake promise.
 
 Good. Let me know where it is when you track it down.
 
 The link you pointed me too doesn't seem to address my question
 directly. Also, it only talks about C.
 
 If I want to call Haskell (and I do, perhaps) from another
 garbage-collected language (Eiffel, in particular) using C as the
 mutually understood language, am I not going to run into big problems?

Read the FFI Report.  It is relatively readable and comprehensive.
http://www.cse.unsw.edu.au/~chak/haskell/ffi/

And yes, you will have to use C as an intermediary, though you may not
have to actually write any C.  You simply expose the Haskell functions
in whatever form the other language expects.  You'll almost certainly
have to write marshalling code of some sort.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread John Goerzen
On Tue, Nov 11, 2008 at 12:35:05PM -0600, Derek Elkins wrote:
 On Tue, 2008-11-11 at 17:09 +, Colin Paul Adams wrote:
   Jake == Jake Mcarthur [EMAIL PROTECTED] writes:
  
  Jake Actually, that's not the whole story. I didn't realize until
  Jake I sent it. There does exist good documentation for this, I
  Jake promise.
  
  Good. Let me know where it is when you track it down.
  
  The link you pointed me too doesn't seem to address my question
  directly. Also, it only talks about C.
  
  If I want to call Haskell (and I do, perhaps) from another
  garbage-collected language (Eiffel, in particular) using C as the
  mutually understood language, am I not going to run into big problems?
 
 Read the FFI Report.  It is relatively readable and comprehensive.
 http://www.cse.unsw.edu.au/~chak/haskell/ffi/
 
 And yes, you will have to use C as an intermediary, though you may not
 have to actually write any C.  You simply expose the Haskell functions
 in whatever form the other language expects.  You'll almost certainly
 have to write marshalling code of some sort.

I often like to look at these situations as an opportunity to
introduce modularity and piping.  Do you really need them running in
the same address space?


 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Don Stewart
colin:
 Is there a way to call Haskell code from other languages? I have looked on
 the wiki, and as far as I can see, it only talks about the other way
 round (when Haskell is the main program).

http://haskell.org/haskellwiki/Calling_Haskell_from_C

Cheers,
  Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Don Stewart
colin:
  Jake == Jake Mcarthur [EMAIL PROTECTED] writes:
 
 Jake Actually, that's not the whole story. I didn't realize until
 Jake I sent it. There does exist good documentation for this, I
 Jake promise.
 
 Good. Let me know where it is when you track it down.
 
 The link you pointed me too doesn't seem to address my question
 directly. Also, it only talks about C.
 
 If I want to call Haskell (and I do, perhaps) from another
 garbage-collected language (Eiffel, in particular) using C as the
 mutually understood language, am I not going to run into big problems?

No, you can manage objects via e.g. ForeignPtr's. The community
has a whole has done bridges between Haskell and pretty much anything
you care to name, via the C FFI. Just depends on how well you understand
the memory management models of both players.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Colin Paul Adams
 John == John Goerzen [EMAIL PROTECTED] writes:

 Read the FFI Report.  It is relatively readable and
 comprehensive.  http://www.cse.unsw.edu.au/~chak/haskell/ffi/
 
 And yes, you will have to use C as an intermediary, though you
 may not have to actually write any C.  You simply expose the
 Haskell functions in whatever form the other language expects.
 You'll almost certainly have to write marshalling code of some
 sort.

John I often like to look at these situations as an opportunity
John to introduce modularity and piping.  Do you really need them
John running in the same address space?

Good point.

And thanks everyone for your help. I have enough to go on now.
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Colin Paul Adams
 Jake == Jake Mcarthur [EMAIL PROTECTED] writes:

Jake Actually, that's not the whole story. I didn't realize until
Jake I sent it. There does exist good documentation for this, I
Jake promise.

Good. Let me know where it is when you track it down.

The link you pointed me too doesn't seem to address my question
directly. Also, it only talks about C.

If I want to call Haskell (and I do, perhaps) from another
garbage-collected language (Eiffel, in particular) using C as the
mutually understood language, am I not going to run into big problems?
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Jake Mcarthur

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Actually, that's not the whole story. I didn't realize until I sent  
it. There does exist good documentation for this, I promise.


- - Jake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkkZuHoACgkQye5hVyvIUKnGeACfZN+9nNy+nGvQHDsG1FrI4Puu
Zw0AmgKK0WOYTjWWeQX93rrnSJApG0pa
=Vazy
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Calling Haskell from other languages?

2008-11-11 Thread Fraser Wilson


I had a proof of concept lying around a couple of years ago in which a  
big complicated Ada program called a big complicated Haskell program  
and vice versa. The tricky bit from memory was making it link, and  
satisfying their rumtime initialisation requirements. No explicit C  
was required I think.


Fraser
On 11 nov 2008, at 18:09, Colin Paul Adams [EMAIL PROTECTED]  
wrote:



Jake == Jake Mcarthur [EMAIL PROTECTED] writes:


   Jake Actually, that's not the whole story. I didn't realize until
   Jake I sent it. There does exist good documentation for this, I
   Jake promise.

Good. Let me know where it is when you track it down.

The link you pointed me too doesn't seem to address my question
directly. Also, it only talks about C.

If I want to call Haskell (and I do, perhaps) from another
garbage-collected language (Eiffel, in particular) using C as the
mutually understood language, am I not going to run into big problems?
--
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe