foreign function interface "Invalid type signature"

What am I doing wrong? module Ffi2 where { import Foreign.C.Types; foo :: CInt -> CInt; foo x = x; foreign export ccall foo :: CInt -> CInt; } $ ghc -c Ffi2.hs Ffi2.hs:8:0: Invalid type signature --ken

On 26 August 2010 10:41, Ken Takusagawa
What am I doing wrong?
module Ffi2 where { import Foreign.C.Types;
foo :: CInt -> CInt; foo x = x;
foreign export ccall foo :: CInt -> CInt;
}
Did you enable the
$ ghc -c Ffi2.hs
Ffi2.hs:8:0: Invalid type signature
You need to call it with -XForeignFunctionInterface to enable FFI methinks. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Thanks, that fixed it.
On Aug 25, 2010 8:47 PM, "Ivan Lazar Miljenovic"
On 26 August 2010 10:41, Ken Takusagawa
wrote: What am I doing wrong?
module Ffi2 where { import Foreign.C.Types;
foo :: CInt -> CInt; foo x = x;
foreign export ccall foo :: CInt -> CInt;
}
Did you enable the
$ ghc -c Ffi2.hs
Ffi2.hs:8:0: Invalid type signature
You need to call it with -XForeignFunctionInterface to enable FFI methinks.
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

The HEAD now does FFI by default (Haskell 2010) so you would not have tripped over this.
But even if you use the -XHaskell98 flag to recover Haskell-98 mode, you get this error:
Foo.hs:9:1:
Invalid type signature: foreign export ccall foo :: CInt -> CInt
Perhaps you meant to use -XForeignFunctionInterface?
Which would have been more helpful for you.
Simon
| -----Original Message-----
| From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-
| bounces@haskell.org] On Behalf Of Ivan Lazar Miljenovic
| Sent: 26 August 2010 01:48
| To: Ken Takusagawa
| Cc: Haskell Cafe
| Subject: Re: [Haskell-cafe] foreign function interface "Invalid type
| signature"
|
| On 26 August 2010 10:41, Ken Takusagawa
participants (3)
-
Ivan Lazar Miljenovic
-
Ken Takusagawa
-
Simon Peyton-Jones