@@ -178,6 +178,12 @@ compilation error:
178 example : (Int -> ()) -> IO ()
178 example : (Int -> ()) -> IO ()
179 example f = foreign FFI_C "callbacker" (CFnPtr (Int -> ()) -> IO ()) f
179 example f = foreign FFI_C "callbacker" (CFnPtr (Int -> ()) -> IO ()) f
181+Note that the function that is used as a callback can't be a closure, that is
182+it can't be a partially applied function. This is because the mechanism used is
183+unable to pass the closed-over values through C. If we want to pass Idris values
184+to the callback we have to pass them through C explicitly. Non-primitive Idris
185+values can be passed to C via the ``Raw`` type.
181The other big limitation is that it doesn't support IO functions. Use
187The other big limitation is that it doesn't support IO functions. Use
182``unsafePerformIO`` to wrap them (i.e. to make an IO function usable as a callback, change the return type
188``unsafePerformIO`` to wrap them (i.e. to make an IO function usable as a callback, change the return type
183from IOr to r, and change the = do to = unsafePerformIO $ do).
189from IOr to r, and change the = do to = unsafePerformIO $ do).