#5529: Newtypes with hidden constructors cannot be passed as FFI arguments
-----------------------------------+----------------------------------------
Reporter: mikhail.vorozhtsov | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.3
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
-----------------------------------+----------------------------------------
Comment(by simonmar):
Replying to [comment:4 mikhail.vorozhtsov]:
> That's not exactly correct. The C code depends on the ''particular'' way
the argument is represented (e.g. passing Int64 instead of Int32 is a bad
idea), but what GHC checks is a general "representability"
(Int64/Int32/Float/..., it doesn't matter as long as it fits the calling
convention) of the type. Constructor exporting is just an overkill for
that task. What we need is a way to mark (with corresponding C types)
appropriate newtypes as being representable (e.g. automatically by the
compiler in module interfaces, or by requesting derivation of a special
type class) without forcing users to spill the guts and when invent
conventions for not hurting themselves ("yes, we export the internals, but
never use them in your code, they are here only to pass FFI checks").
I don't understand. Using a newtype in a foreign call exposes its
representation, because it only works if you match the representation type
with the type expected by the C function. So marking newtypes as
"representable" doesn't help - you really have to know the representation.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5529#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs