[Haskell-cafe] type inference and FFI
sylvain at haskus.fr
Wed Oct 27 10:00:38 UTC 2021
With a type-class maybe?
class Foo a where
foo :: Ptr a -> IO r -- not sure what is your `r`
instance Foo Word16 where foo = c'foo_uint16_t
instance Foo Word32 where foo = c'foo_uint32_t
On 27/10/2021 11:18, PICCA Frederic-Emmanuel wrote:
> Hello, I have a bunch of C method that I need to call like this
> c'foo_unit16_t :: Ptr Word16 -> IO r
> c'foo_uint32_t :: Ptr Word32 -> IO r
> These methodes are called from a method like this
> process :: NativeType t => Dataframe t => IO r
> process df = do
> <pseudo code>
> case typeof t of
> WORD16 -> c'foo_unit16_t ...
> WORD32 -> c'foo_uint32_t ...
> Since there is type erasure, I would like to know what is the best way to write this process method.
> thanks for you help
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
More information about the Haskell-Cafe