Storable which is only Peekable

Hello, I would like to know what is the best way to create a type which is only peekable and pokable. When I use Storable, I "need" to define peek and poke and ghc complain that I did not defined the poke part. So how can I write something nice. Cheers Frederic #include "hkl-binoculars.h" data Space = Space (ForeignPtr Space) Int deriving Show foreign import ccall safe "fromImage" c_fromImage :: Ptr Double -> Int -> Ptr Double -> Ptr Int -> Int -> Ptr Word16 -> Ptr Int -> Int -> IO (Ptr Space) foreign import ccall unsafe "&space_free" c_space_free :: FunPtr (Ptr Space -> IO ()) instance Storable Space where alignment _ = #{alignment struct space_t} sizeOf _ = #{size struct space_t} peek ptr = Space <$> newForeignPtr c_space_free ptr <*> #{peek struct space_t, ndim} ptr
participants (1)
-
PICCA Frederic-Emmanuel