From b45e37124d855bdf3365e8202559c45cf28e9d88 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 30 Mar 2019 16:08:18 +0100 Subject: first success with ffi (Call hask from c) --- ffi/Foo.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ffi/Foo.hs (limited to 'ffi/Foo.hs') diff --git a/ffi/Foo.hs b/ffi/Foo.hs new file mode 100644 index 0000000..286a8bf --- /dev/null +++ b/ffi/Foo.hs @@ -0,0 +1,10 @@ +module Foo where + +foreign export ccall foo :: Int -> IO Int + +foo :: Int -> IO Int +foo n = return (length (f n)) + +f :: Int -> [Int] +f 0 = [] +f n = n:(f (n-1)) -- cgit v1.2.3