Open dbeacham opened 8 years ago
I've run into something very similar to fix alongside the above, when the (admittedly low priority) bug does get addressed: those same two imports are added even if the macro includes nocode
. The type safety (-> Test
) doesn't affect things.
Basically, it seems like every #pointer
macro imports Foreign.Ptr
and every #pointer ... foreign
also imports Foreign.ForeignPtr
. In certain cases, those are not necessary:
#pointer ... nocode
never needs any imports; the user will probably need them in defining the type, but even if that does occur in the same module, they'll probably be using their own qualified name.#pointer ... foreign
needs Foreign.Ptr
only if newtype
is also specified; otherwise C2HS doesn't create the with*
marshalling function that uses it.I suppose it's possible that the registration requires those types to be present, but not knowing the backend code, I'd guess it's probably fine leaving (or moving) the importing of those modules to #fun
or other macros, which would probably be needing them for other reasons anyway.
e.g.
generates
The extra (unused)
Foreign.Ptr
import blows up on-Werror
.