Exporting GHC functions.

Thomas L. Bevan thomas_bevan@toll.com.au
Thu, 31 Jul 2003 16:20:43 +0000


--Boundary-00=_bHUK/OPx6+gbeno
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Description: clearsigned data
Content-Disposition: inline

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here is a copy of all the files I am using to try to export a Haskell=20
function.

This compiles but produces a executable that simply hangs.

Tom
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/KUHbYha8TWXIQwoRAs8RAKCIFcnH9uuqfMpDYXA0gfFjBtMfEwCgjZeD
5dkfLbz/lz4btmsR9G4kL2A=3D
=3DpCBN
=2D----END PGP SIGNATURE-----

--Boundary-00=_bHUK/OPx6+gbeno
Content-Type: text/plain;
  charset="us-ascii";
  name="compile"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="compile"

ghc -ffi -fvia-c -c Hello.hs
ar -rc libhello.a Hello.o Hello_stub.o
ghc -L. -lhello -I. -I/usr/lib/ghc-6.0/include -o helloworld integrate.c 

--Boundary-00=_bHUK/OPx6+gbeno
Content-Type: text/plain;
  charset="us-ascii";
  name="Hello.hs"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="Hello.hs"

module Hello where

foreign export "hello" hello :: IO ()


hello :: IO ()
hello = do putStrLn "Hello world!"

--Boundary-00=_bHUK/OPx6+gbeno
Content-Type: text/x-csrc;
  charset="us-ascii";
  name="integrate.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="integrate.c"

#include <Hello_stub.h>
#include <HsFFI.h>
#include <stdio.h>

int main(){

	printf( "Hello there." );
	
	hello();
	
	exit( 0 );

}

--Boundary-00=_bHUK/OPx6+gbeno--