File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " haskell-to-rust"
3
+ version = " 0.1.0"
4
+ authors = [
" Bill Murphy <[email protected] >" ]
5
+
6
+ [lib ]
7
+ name = " double_input"
8
+ crate-type = [" dylib" ]
Original file line number Diff line number Diff line change
1
+ ifeq ($(shell uname) ,Darwin)
2
+ EXT := dylib
3
+ else
4
+ EXT := so
5
+ endif
6
+
7
+ all : target/debug/libdouble_input.$(EXT )
8
+ ghc src/Main.hs target/debug/libdouble_input.$(EXT ) -o main
9
+
10
+ target/debug/libdouble_input.$(EXT ) : src/lib.rs Cargo.toml
11
+ cargo build
12
+
13
+ clean :
14
+ rm -rf target
15
+ rm main
16
+ rm src/* .o src/* .hi
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE ForeignFunctionInterface #-}
2
+
3
+ import Foreign.C
4
+
5
+ foreign import ccall " double_input" doubleInput :: CInt -> CInt
6
+
7
+ main = do
8
+ let input = 4
9
+ let output = doubleInput input
10
+ putStrLn $ show input ++ " * 2 = " ++ show output
Original file line number Diff line number Diff line change
1
+ #[ no_mangle]
2
+ pub extern fn double_input ( input : i32 ) -> i32 {
3
+ input * 2
4
+ }
You can’t perform that action at this time.
0 commit comments