Skip to content

Instantly share code, notes, and snippets.

@aavogt
Last active August 29, 2015 14:05
Show Gist options
  • Save aavogt/70f55aa85287f0046f3b to your computer and use it in GitHub Desktop.
Save aavogt/70f55aa85287f0046f3b to your computer and use it in GitHub Desktop.
ghc does not check foreign import types
double f (double x) {
return (x*2);
}
double f (double x);
{-# LANGUAGE ForeignFunctionInterface #-}
foreign import ccall "a.h f" f :: Int -> Int
main = print (f 3)
{-
ghc a.h a.c main.hs
./main
130560
prints 6.0 if you give f :: Double -> Double
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment