
23 Jan
2021
23 Jan
'21
2:34 a.m.
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... 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.