[Haskell-cafe] Help Haskell driving Medical Instruments

Jason Dusek jason.dusek at gmail.com
Tue Nov 10 15:09:57 EST 2009

2009/11/10 Philippos Apolinarius <phi500ac at yahoo.ca>
> I don't know how to mark the call unsafe. [...] I am running
> the main program on Windows.

  Marking it unsafe is done by putting "unsafe" in the foreign
  import declaration. Even if it turns out not to fix the
  problem, it reduces the overhead of foreign calls (and is safe
  as long as they aren't going to call back into Haskell).

  Because your on Windows, you want to use "stdcall", as
  mentioned by Daniel Fischer. Thus the full declaration is:

    foreign import stdcall unsafe "rs232.h closecport" closecport :: IO ()

  Let us know if this helps.

> Here is the compilation script:
> ghc -fglasgow-exts serial.c  %1.hs -L./ -ljapi --make
> erase *.hi
> erase *.o
> strip %1.exe

  I encourage you to look into Cabal soon :)

Jason Dusek

More information about the Haskell-Cafe mailing list