summaryrefslogtreecommitdiff
path: root/ffi/Foo.hs
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2019-03-30 16:08:18 +0100
committerMiguel <m.i@gmx.at>2019-03-30 16:08:18 +0100
commitb45e37124d855bdf3365e8202559c45cf28e9d88 (patch)
tree1741d955c0c8e023a0c3bead76795bfbd895e7bb /ffi/Foo.hs
parent1ac8773f20c25b9ebbe559efe25591ba7a24acdb (diff)
first success with ffi (Call hask from c)
Diffstat (limited to 'ffi/Foo.hs')
-rw-r--r--ffi/Foo.hs10
1 files changed, 10 insertions, 0 deletions
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))