FFI proposal: allow some control over the scope of C header files

Simon Marlow simonmar at microsoft.com
Mon Apr 24 09:44:50 EDT 2006

How about just adding a couple of new pragmas:

 {-# INCLUDE_PRIVATE "foo/bar.h" #-}
 {-# INCLUDE_PACKAGE "foo/bar.h" #-}

both pragmas apply to all the foreign imports in the current module,
just like the existing INCLUDE pragma.  Additionally, INCLUDE_PRIVATE
prevents any foreign import from being inlined outside the current
module, and INCLUDE_PACKAGE does the same but for the package (this
requires a little more support from GHC).

We can then describe more accurately what is means to give an include
file on a particular foreign import: it means the same as
INCLUDE_PRIVATE, but for this foreign import only.

The problem you mentioned, namely that people use a private header file
but don't export it with the package, only happens when they explicitly
use {-# INCLUDE #-} or -#include flags, right?  In that case, we can
have Cabal check that all {-# INCLUDE #-} files are properly exported
with the package, and discourage the use of explicit -#include options.
Is that enough?


More information about the Haskell-prime mailing list