Open Magicloud opened 5 years ago
Is there a reason you can't make your C2HS modules Internal
and only export the ones you care about in some public facing one?
I understand this isn't ideal but I'm not sure C2HS should be generating modules in your project tree.
To your first point, let me think about it. Do you have an export
syntax in mind?
Sorry, I may not make myself clear. By using Internal
, I meant to put the ccall-s in that, not C2HS wrappers. So the "normal" module would be clean that only contains the functions I defined with fun
hook. Thus I do not need to bother with module exporting list.
For export
syntax, I think a simple comma list satisfies. Something like
module Text (MyType, {#export#}) where
data MyType
{#fun c_fun#}
would exports Test.MyType
, Text.c_fun
.
Did you mean {#export c_fun#}
or does {#export#}
mean to export all the C2HS generated functions?
I am thinking exporting all. If I need to write individual function names, it seems no difference than current manual way.
I think C2HS tends to ease the process of writing of FFI. And it provides a ^ in fun so I do not need to care about the naming. This is all cool.
But since C2HS generates all ccall-s with name'_ in the same module, I must either write a exporting list, which includes all the names I did not care, or show some weird things in IDE intelligent sense or doc by haddock.
Could C2HS also take care of this? I can think of two ways. One, provide a syntax for exporting list. Two, move all ccall-s into another module like STH.Internal.