I have a module (Safe.hs
) with
foreign export ccall respond_hs :: CWString -> IO CWString
for FFI with C.
I'd like to load Safe.hs
in GHCi and evaluate some things with it.
But ghci
fails to load it (I'm specifying two source files because it depends on valencies.lhs
):
$ ghci src/valencies.lhs src/Safe.hs
GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 2] Compiling Valencies ( src/valencies.lhs, interpreted ) [flags changed]
[2 of 2] Compiling Safe ( src/Safe.hs, interpreted )
src/Safe.hs:10:1:
Illegal foreign declaration: requires via-C, llvm (-fllvm) or native code generation (-fvia-C)
When checking declaration:
foreign export ccall "respond_hs" respond_hs
:: CWString -> IO CWString
Failed, modules loaded: Valencies.
*Valencies> :q
Leaving GHCi.
$
Giving -fvia-C
option doesn't help.
Related questions
This is a different question from Testing FFI Code with GHCi, where the point was in testing Haskell code with
foreign import
(notexport
) from C libraries.GHCi doesn't work with FFI export declarations/shared libaries seems strange to me, because it doesn't help me. It deals with
foreign export
from Haskell to C, but the problem solved there is some missing object files.