2 {-# LANGUAGE ForeignFunctionInterface #-}
11 import Prelude hiding (min, max)
13 import Foreign ( ForeignPtr
18 import Foreign.C (CInt(..))
28 withDetector :: Detector a -> (Ptr HklDetector -> IO b) -> IO b
29 withDetector d func = do
31 withForeignPtr fptr func
33 newDetector :: Detector a -> IO (ForeignPtr HklDetector)
34 newDetector ZeroD = c_hkl_detector_new 0 >>= newForeignPtr c_hkl_detector_free
35 newDetector _ = error "Can not use 2D detector with the hkl library"
37 foreign import ccall unsafe "hkl.h hkl_detector_new"
38 c_hkl_detector_new:: CInt -> IO (Ptr HklDetector)
40 foreign import ccall unsafe "hkl.h &hkl_detector_free"
41 c_hkl_detector_free :: FunPtr (Ptr HklDetector -> IO ())