#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 mikhail.vorozhtsov):

 Replying to [comment:3 simonmar]:
 > I think GHC is correct now.  This was discussed a long time ago on the
 FFI list (no link handy, sorry), and I think the principle is that in
 order to use a newtype in an FFI declaration you have to know its
 representation, because you're linking against some known C code that
 depends on the representation.

 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").

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5529#comment:4>
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

Reply via email to