HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulererebase-1.21.2Haskell2010

Foreign.C.String

  • 4 types
  • 25 values
  • Packagererebase-1.21.2
  • Exports29
  • LanguageHaskell2010
  • LicenceMIT
  • SourceEncoding.hs
typetype CString = Ptr CChar
#

A C string is a reference to an array of C characters terminated by NUL.

typetype CStringLen = (Ptr CChar, Int)
#

A string with explicit length information in bytes instead of a terminating NUL (allowing NUL characters in the middle of the string).

valuewithCString :: String -> (CString -> IO a) -> IO a
#

Marshal a Haskell string into a NUL terminated C string using temporary storage.

  • the Haskell string may not contain any NUL characters

  • the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

valuenewCString :: String -> IO CString
#

Marshal a Haskell string into a NUL terminated C string.

  • the Haskell string may not contain any NUL characters

  • new storage is allocated for the C string and must be explicitly freed using free or finalizerFree.

valuewithCAStringLen :: String -> (CStringLen -> IO a) -> IO a
#

Marshal a Haskell string into a C string (ie, character array) in temporary storage, with explicit length information.

  • the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

valuewithCAString :: String -> (CString -> IO a) -> IO a
#

Marshal a Haskell string into a NUL terminated C string using temporary storage.

  • the Haskell string may not contain any NUL characters

  • the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

valuewithCStringLen :: String -> (CStringLen -> IO a) -> IO a
#

Marshal a Haskell string into a C string (ie, character array) in temporary storage, with explicit length information.

  • the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

valuecastCCharToChar :: CChar -> Char
#

Convert a C byte, representing a Latin-1 character, to the corresponding Haskell character.

valuecastCSCharToChar :: CSChar -> Char
#

Convert a C signed char, representing a Latin-1 character, to the corresponding Haskell character.

valuecastCUCharToChar :: CUChar -> Char
#

Convert a C unsigned char, representing a Latin-1 character, to the corresponding Haskell character.

valuecastCharToCChar :: Char -> CChar
#

Convert a Haskell character to a C character. This function is only safe on the first 256 characters.

valuecastCharToCSChar :: Char -> CSChar
#

Convert a Haskell character to a C signed char. This function is only safe on the first 256 characters.

valuecastCharToCUChar :: Char -> CUChar
#

Convert a Haskell character to a C unsigned char. This function is only safe on the first 256 characters.

valuenewCAString :: String -> IO CString
#

Marshal a Haskell string into a NUL terminated C string.

  • the Haskell string may not contain any NUL characters

  • new storage is allocated for the C string and must be explicitly freed using free or finalizerFree.

Marshal a Haskell string into a C string (ie, character array) with explicit length information.

  • new storage is allocated for the C string and must be explicitly freed using free or finalizerFree.

valuenewCWString :: String -> IO CWString
#

Marshal a Haskell string into a NUL terminated C wide string.

  • the Haskell string may not contain any NUL characters

  • new storage is allocated for the C wide string and must be explicitly freed using free or finalizerFree.

Marshal a Haskell string into a C wide string (ie, wide character array) with explicit length information.

  • new storage is allocated for the C wide string and must be explicitly freed using free or finalizerFree.

valuewithCWString :: String -> (CWString -> IO a) -> IO a
#

Marshal a Haskell string into a NUL terminated C wide string using temporary storage.

  • the Haskell string may not contain any NUL characters

  • the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

valuewithCWStringLen :: String -> (CWStringLen -> IO a) -> IO a
#

Marshal a Haskell string into a C wide string (i.e. wide character array) in temporary storage, with explicit length information.

  • the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

typetype CWString = Ptr CWchar
#

A C wide string is a reference to an array of C wide characters terminated by NUL.

typetype CWStringLen = (Ptr CWchar, Int)
#

A wide character string with explicit length information in CWchars instead of a terminating NUL (allowing NUL characters in the middle of the string).