Newtype unwrapping in the FFI
Simon Peyton-Jones
simonpj at microsoft.com
Thu Feb 12 07:35:35 EST 2009
| > * Clarify the spec to say that a newtype can only be automatically
| > unwrapped if the newtype constructor (MkN in this case) is in
| > scope
|
| I agree up to here. For user-defined types, not exporting the
| constructor should be a guarantee of abstraction.
|
| > It happens that a large set of types from Foreign.C.Types, such as
| > CInt and friends, are exported without their constructors, so adopting
| > this new rule would require us to change Foreign.C.Types to expose the
| > representation of CInt and friends. (As it happens, nhc requires this
| > already, so there's some #ifdeffery there already.)
|
| The thing about CInt though is that it is supposed to be abstract *and*
| an FFI type. I want to think of it as a primitive FFI type (though it is
| not a "basic" type as defined by the FFI). We don't want to know that on
| some system it is Int32 and on others it is Int64. We do not want access
| to the constructor here.
Trouble is, there are a zillion types in Foreign.C.Types, and another zillion in Foreign.Posix.Types. Do you want to list them all as "blessed" in the FFI addendum?
S
More information about the Haskell-prime
mailing list