[Haskell-beginners] ffi array and peekArray
PICCA Frederic-Emmanuel
frederic-emmanuel.picca at synchrotron-soleil.fr
Thu Nov 26 12:50:49 UTC 2015
Thanks a lot it works now :)
________________________________________
De : Beginners [beginners-bounces at haskell.org] de la part de Sylvain Henry [hsyl20 at gmail.com]
Envoyé : dimanche 8 novembre 2015 21:45
À : The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell
Objet : Re: [Haskell-beginners] ffi array and peekArray
You can alias HklFactory:
type HklFactory = Ptr ()
Or if you want to avoid mixing HklFactory and other pointers, you can use:
newtype HklFactory = HklFactory (Ptr ()) deriving (Storable)
The latter requires the GeneralizedNewtypeDeriving extension, see: https://wiki.haskell.org/Foreign_Function_Interface#Renaming_and_Storable_instances
Sylvain
2015-11-08 21:30 GMT+01:00 PICCA Frederic-Emmanuel <frederic-emmanuel.picca at synchrotron-soleil.fr<mailto:frederic-emmanuel.picca at synchrotron-soleil.fr>>:
Ok, so now I get this error
ghkl.hs:20:18:
No instance for (Foreign.Storable.Storable HklFactory)
arising from a use of ‘peekArray’
In a stmt of a 'do' block: peekArray n factories
In the expression:
do { factories <- c_hkl_factory_get_all ptr;
n <- peek ptr;
peekArray n factories }
In the second argument of ‘($)’, namely
‘\ ptr
-> do { factories <- c_hkl_factory_get_all ptr;
n <- peek ptr;
.... }’
What should I do to create a Storable for HklFactory which is a simple pointer.
Thanks
Frederic
_______________________________________________
Beginners mailing list
Beginners at haskell.org<mailto:Beginners at haskell.org>
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
More information about the Beginners
mailing list