expose strlen from Foreign.C.String
Viktor Dukhovni
ietf-dane at dukhovni.org
Sat Jan 23 02:34:18 UTC 2021
On Fri, Jan 22, 2021 at 06:07:22PM -0800, Eric Mertens wrote:
> I’m on board with this import, but we’ll need to get the type right if
> we’re going to bind to libc’s strlen directly
>
> foreign import unsafe "strlen"
> cstringLength :: CString -> IO CSize
Yes, definitely. The final all-nits-addressed variant would be:
foreign import ccall unsafe "string.h strlen"
cstringLength :: CString -> IO CSize
which is differs from the example in section 8.4.3 of the Haskell 2010
report
https://www.haskell.org/onlinereport/haskell2010/haskellch8.html#x15-1590008.4.3
foreign import ccall "string.h strlen"
cstrlen :: Ptr CChar -> IO CSize
only in the addition of "unsafe" and the name of the resulting function.
--
Viktor.
More information about the Libraries
mailing list