- State “DONE” from “TODO” [2019-11-09 Sat 17:28]
import System.Posix.DynamicLinker
import Foreign.Ptr
import Foreign.LibFFI
main = do
malloc <- dlsym Default "malloc"
memset <- dlsym Default "memset"
p <- callFFI malloc (retPtr retVoid) [argCSize (2^30)]
callFFI memset (retPtr retVoid) [argPtr p, argCInt 0, argCSize (2^30)]
callFFI memset (retPtr retVoid) [argPtr nullPtr, argCInt 0, argCSize 1]
From http://hackage.haskell.org/package/libffi-0.1/docs/Foreign-LibFFI.html
- State “DONE” from “TODO” [2019-10-27 Sun 11:38]
data Op = PrimOp PrimOp + | ForeignOp CCallSpec
prana-interpreter> [1 of 1] Recompiling Atan2 [prana] prana-interpreter> [1 of 1] Converting Atan2 [prana] prana-interpreter> prana-interpreter-test: panic! (the 'impossible' happened) prana-interpreter> (GHC version 8.4.3 for x86_64-unknown-linux): prana-interpreter> Unexpected function for data alt case scrutinee.
{-# LANGUAGE NoImplicitPrelude #-}
-- | Demonstrate various use of the FFI.
module Atan2 where
import Foreign.C
foreign import ccall "math.h atan2"
atan2 :: CDouble -> CDouble -> CDouble
it :: CDouble
it = atan2 (-10) (10) * 180 / 3.14159265