haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
199 stars 50 forks source link

Is it possible to share type definitions between packages? #228

Open Magicloud opened 5 years ago

Magicloud commented 5 years ago

My routine for one binding package is that, a Types.chs for all pointer hook, and some modules containing fun hooks and using Types via import hook.

But when I made another binding package using the same Types (so those two packages can work with each other), since I do not have Types.chs in the second package, I cannot use import hook. And thus, seems like, C2HS knows nothing about the types. And generates ccall-s with wrong signature, for example, IO (Ptr ()) instead of IO (Ptr MyType).

Magicloud commented 5 years ago

I am manually copying .chi between packages. It works. But requires some manually maintain. I am afraid it would lose sync. Wondering if there is a better way.