ffi002.hs 201 Bytes
Newer Older
Ian Lynagh's avatar
Ian Lynagh committed
1
{-# LANGUAGE ForeignFunctionInterface #-}
rrt's avatar
rrt committed
2
3
module Foo where

Simon Marlow's avatar
Simon Marlow committed
4
foreign export ccall foo :: Int -> IO Int
rrt's avatar
rrt committed
5
6
7
8
9
10
11
12

foo :: Int -> IO Int
foo n = return (length (f n))

f :: Int -> [Int]
f 0 = []
f n = n:(f (n-1))