Closed albertov closed 8 years ago
@albertov Thanks for the report. I'm not surprised that you found a hole in the new import management stuff. To be honest, I was expecting a lot more problems with it! I'll take a look at this some time this week.
I think this should be fixed in HEAD now.
I'm not seeing Ptr exported by Foreign.C.Types
- shouldn't this import be Foreign.Ptr
?
Prelude> import Foreign.C.Types
Prelude Foreign.C.Types> :i Ptr
<interactive>:1:1: Not in scope: ‘Ptr’
Prelude Foreign.C.Types> import Foreign.Ptr
Prelude Foreign.C.Types Foreign.Ptr> :i Ptr
type role Ptr phantom
data Ptr a = GHC.Ptr.Ptr GHC.Prim.Addr#
-- Defined in ‘GHC.Ptr’
@TomMD That's right, but if you have a .chs
file with a {#pointer ...#}
hook in it, C2HS generates Haskell with the imports
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp
so you get both the things that are needed. The problem in this issue was just that I'd forgotten to do the import collection for some kinds of pointer hooks -- I have a function that traverses a representation of the Haskell type corresponding to values needed by C2HS hooks and works out what library modules to import, and that works fine. I just wasn't calling it in the right place.
c2hs 0.26.1 seems to forget to add an import for
C2HSImp
as can be seen in the failing build here.The offending is code seems to be a
{#pointer #}
to a function pointer type in this lineAdding
import qualified Foreign.C.Types as C2HSImp
fixes the problem.