[Haskell-cafe] FFI basics

Yitzchak Gale gale at sefer.org
Mon Feb 12 03:54:15 EST 2007


Bulat Ziganshin wrote:
> examples of lifting C functions into Haskell world:
>
> mysin :: Double -> Double
> mysin = realToFrac . c_mysin . realToFrac
>
> -- c_mysin :: CDouble -> CDouble
>
> rnd :: Int -> IO Int
> rnd x = do r <- c_rnd (fromIntegral x)
>            return (fromIntegral r)
>
> -- c_rnd :: CInt -> IO CInt

OK, got it. I'll put that in.

Thanks,
Yitz


More information about the Haskell-Cafe mailing list