[EMAIL PROTECTED] (Marcin 'Qrczak' Kowalczyk) wrote,
> 6 Jul 1999 16:02:26 GMT, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> pisze:
>
> > Is it possible to give C functions linked into a Haskell module the
> > ability to call various Haskell IO functions?
>
> Ah, I think I've found it (foreign export), but it does not work
> with ghc-4.02 (the "glibc version" from Simon Marlow - it no longer
> crashes on fflush, thanks!):
>
> [qrczak ~/haskell]$ cat M.hs
> module M (call_h) where
> call_h = putStrLn "Hello\n"
> foreign export "call_h" call_h :: IO ()
> [qrczak ~/haskell]$ ghc -c M.hs -fglasgow-exts
>
> Name.lhs:369: Non-exhaustive patterns in function nameSortModule
>
>
> [qrczak ~/haskell]$
>
> As I can't build ghc from sources and fix the problem myself, is
> there any workaround?
At least `foreign export ccall dynamic' seems to work.
Maybe you can use that for the moment.
> How is `foreign import' interface related to _ccall_? Is the first
> now preferable or they both will be equally continued?
Currently, `foreign import' is internally mapped to
`_ccall_'. However, the former takes care that you
arguments are evaluated and it is the cleaner and more
flexibel approach -- which I very much hope will eventually
find its way into the standard.
Manuel