[Haskell-beginners] while loop
frederic-emmanuel.picca at synchrotron-soleil.fr
Thu Feb 11 11:02:45 UTC 2016
I am playing with FFI and I need to extract from a C API a list of pointers.
I have two methods available
c_get_first_item :: Ptr List -> IO (Ptr Item)
c_get_next_item :: Ptr List -> Ptr Item -> IO (Ptr Item)
I would like to obtain a [Ptr Item]
I try to used whileM but I did not find how to inject the first item in the loop.
whileM (return . ( /= nullPtr)) (c_get_next_item list item)
the c_get_next_item return a nullPtr when there is no remaining item.
what is the haskell way in order to extract a list of pointer using these C methods ?
thanks for your help
More information about the Beginners