Closed VyacheslavHashov closed 7 years ago
There is already System.Socket.Unsafe
.
It is a common practice that exposed functions works with Int, not CInt/CSize because they would be more usable. Is it feasible to rewrite all unsafe functions with accordance to this rule?
Mhh, open for discussion.
The ByteString library has useAsCStringLen
where CStringLen
is an alias for (Ptr CChar, CSize). I thought it's not too unusual that one rather has a
CSizethan an
Int` when dealing with pointers and having allocated the buffer elsewhere.
useAsCStringLen :: ByteString -> (CStringLen -> IO a) -> IO a
As for example, allocating functions in Foreign.ForeignPtr
work with Int
s. But I have taken your point. If a function already has Ptr
in the signature than changing CInt
to Int
gives no appreciable benefit.
One more point for future readers:
CSize
is Word64
whereas an Int
is only guaranteed to be defined up to 2^29.
With these signatures or similar:
They might be useful in the following scenarios: