The Foreign.C.String
module contains the type
-- | A string with explicit length information in bytes instead of a
-- terminating NUL (allowing NUL characters in the middle of the string).
type CStringLen = (Ptr CChar, Int)
However, as far as I understand, string lengths are conventionally given as size_t
in C, i.e., Foreign.C.Types.CSize
in Haskell. E.g., that’s the type returned by strlen
. As a result, my code is often riddled with calls to fromIntegral
to convert from Int
to CSize
, which is annoying.
Is this just a historical accident, or does it have a deeper meaning? If the former, is there any chance this can be changed in future versions of base? How would one go about that?