c2hs
c2hs copied to clipboard
In what case would c2hs import Foreign.Ptr?
I have two pointers defined in exactly the same way. And two modules contains fun definitions for each pointer. One of them built well. The other complains on unknown type Ptr. Apparently, in the second .hs file, a few imports are missing. I could not figure out what caused the difference.
error message
Not in scope: type constructor or class ‘C2HSImp.Ptr’
Neither ‘Foreign.C.Types’ nor ‘Foreign.ForeignPtr’ exports ‘Ptr’.
pointer definition
{#pointer *c_typedef as Typedef foreign finalizer typedef_destroy newtype#}
broken .hs generated
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import MyTypes
working .hs generated
import qualified Foreign.C.String as C2HSImp
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import MyTypes
import Foreign -- I have this in .chs
I also got another issue that Foreign.Marshal is not imported when I need with and alloca. And Foreign.Storable when I need peek.