blob: 7249c8d0ecfb11e0e2de83f42ecd97ebe3dd3a7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
{-# LANGUAGE Safe #-}
{-# LANGUAGE ForeignFunctionInterface #-}
-- | Make sure FFI must be IO type
module Main where
import Foreign.C
foreign import ccall "SafeLang08_A" c_sin :: CDouble -> CDouble
sinx :: Double -> Double
sinx d = realToFrac $ c_sin $ realToFrac d
x :: Double
x = 0.8932
main :: IO ()
main = do
putStrLn "Hello World"
putStrLn $ "Sin of " ++ (show x) ++ " is " ++ (show $ sinx x)
|