Re: expose strlen from Foreign.C.String
Viktor Dukhovni <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.libraries |
|---|---|
| Message-ID | <YAuLKh+A7u/[email protected]> |
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.
_______________________________________________
Libraries mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries