Make choice between newtype
and type
configurable
#308
Labels
enhancement
New feature or request
Milestone
We can do this at two levels:
newtype
s ortype
aliases for C typedefs (which would then apply totypedef int my_clock_t
as well astypedef struct foo foo_s
equally). Currently the default here is to usenewtype
s everywhere (see also Is typedef a type or a newtype or? #173)hs-bindgen
as a library (see below).Background:
In #306 we discussed what to do with things like
The conclusion was that we'd want to generate a Haskell
newtype
forfoo_s
, unlessfoo_s
andfoo
are spelled identically.We could alternatively make
foo_s
a Haskell type alias forfoo
, but this feels somewhat inconsistent with #173; in particular, although it is hard to imagine that we might want different type class instances forfoo
andfoo_s
in this example, it's entirely conceivable we might have something likeelsewhere in the header file for which we do want to generate a
newtype
. One could imagine heuristics such asfoo
andfoo_s
are "sufficiently similar" (_s
suffix, ..?)foo
andfoo_s
are "suffiently closely" defined (same C definition, consecutive lines, ..)but unless we can find rules that seem to apply quite universally, it might be better to leave these to individual users (using hs-bindgen`-as-a-library); we should however provide the necessary hooks to implement such rules.
The text was updated successfully, but these errors were encountered: