[Haskell-cafe] foreign function interface "Invalid type signature"

Simon Peyton-Jones simonpj at microsoft.com
Thu Aug 26 10:18:09 EDT 2010


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 at haskell.org [mailto:haskell-cafe-
| bounces at 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 <ken.takusagawa.2 at gmail.com> 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 at gmail.com
| IvanMiljenovic.wordpress.com
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list