[Haskell-beginners] Strorable and incomplete type

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Mon Jun 27 16:49:46 UTC 2016


Hello,

I would like to use Storable and declare an instance for a struct available in a C library

instance Storable Parameter where
    sizeOf _ = #{size HklParameter}
    peek ptr = alloca $ \pmin ->
               alloca $ \pmax -> do
                              cname <- c_hkl_parameter_name_get ptr
                              name <- peekCString cname
                              value <- c_hkl_parameter_value_get ptr unit
                              c_hkl_parameter_min_max_get ptr pmin pmax unit
                              min <- peek pmin
                              max <- peek pmax
                              return (Parameter name value (Range min max))


but when I try to compile this, I get this error message

C.hsc:507:15: error: invalid application of ‘sizeof’ to incomplete type ‘HklParameter’

Indeed the C library do not expose this struct internal.

So I would like to know how to handle this kind of C struct with Storable.

thanks for your help

Frédéric


More information about the Beginners mailing list