From fa49e0bf71ccd4bc98df0fa83546250c1b849e2e Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 11 Apr 2021 03:37:32 +0200 Subject: simple ffi with rust and haskell so far, only calling rust from haskell, not the other way round. --- rusty-haskell/haskell/src/FLib.hs | 8 ++++++++ rusty-haskell/haskell/src/Main.hs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 rusty-haskell/haskell/src/FLib.hs create mode 100644 rusty-haskell/haskell/src/Main.hs (limited to 'rusty-haskell/haskell/src') diff --git a/rusty-haskell/haskell/src/FLib.hs b/rusty-haskell/haskell/src/FLib.hs new file mode 100644 index 0000000..7fc1d61 --- /dev/null +++ b/rusty-haskell/haskell/src/FLib.hs @@ -0,0 +1,8 @@ +module FLib where + +import Foreign.C.Types +import Foreign.C.String + +foreign import ccall "double_input" doubleInput :: CInt -> CInt +--foreign import ccall unsafe "print_string" printString :: CString -> IO () +foreign import ccall "print_hello" printHello :: IO () diff --git a/rusty-haskell/haskell/src/Main.hs b/rusty-haskell/haskell/src/Main.hs new file mode 100644 index 0000000..2c6a7ae --- /dev/null +++ b/rusty-haskell/haskell/src/Main.hs @@ -0,0 +1,16 @@ +module Main where + + +import Foreign.C.Types +import Foreign.C.String + +foreign import ccall "double_input" doubleInput :: CInt -> CInt +--foreign import ccall unsafe "print_string" printString :: CString -> IO () +foreign import ccall "print_hello" printHello :: IO () + + +main :: IO () +main = do + let b = doubleInput 2 + printHello + putStrLn $ show b -- cgit v1.2.3