FFI : A failing example

Hal Daume III hdaume@ISI.EDU
Mon, 21 Oct 2002 20:34:21 -0700 (PDT)


There was (two days ago or so) a sequence of posts about this.  You need
the command line option -ffi.

--
Hal Daume III

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Tue, 22 Oct 2002, Francis Girard wrote:

> Hello,
> 
> I'm a beginner trying to use FFI. I copied the example given in :
> 
> The Glasgow Haskell Compiler User's Guide, Version 5.04
> Chapter 8. Foreign function interface (FFI)
> 
> --------------------------------------------------------------------------
> module Foo where
> 
> foreign export ccall foo :: Int -> IO Int
> 
> foo :: Int -> IO Int
> foo n = return (length (f n))
> 
> f :: Int -> [Int]
> f 0 = []
> f n = n:(f (n-1))
> --------------------------------------------------------------------------
> 
> Copied it verbatim. And simply tried to compile it using "ghc -c Foo.hs -o 
> Foo.o" and always got the error :
> 
> Type signature given for an expression (at the line following the "foreign 
> export")
> 
> I then tried to import the "Foreign" and "Foreign.C" modules but it didn't 
> change anything.
> 
> I am missing something and I would be VERY grateful to anyone that tells me 
> what.
> 
> Thank you
> 
> Francis Girard
> Le Conquet (France)
> Francis.Girard@free.fr
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>