Safe Haskell | None |
---|---|
Language | Haskell98 |
This module provides immutable CStrings, which additionally have the property that they are automatically freed when the garbage-collector forgets about them.
Synopsis
- data ICStringLen
- newtype UTF8 bytes = UTF8 bytes
- toUTF8 :: Enum byte => String -> [byte]
- fromUTF8WE :: (Enum byte, Monad m) => [byte] -> m String
- mkICStringLen :: Int -> (CString -> IO ()) -> IO ICStringLen
- mkICStringLenExtra :: Int -> (CString -> IO extra) -> IO (ICStringLen, extra)
- withICStringLen :: ICStringLen -> (Int -> CString -> IO a) -> IO a
- bytesToICStringLen :: (Bytes, Int) -> IO ICStringLen
- bytesFromICStringLen :: ICStringLen -> (Bytes, Int)
- touchICStringLen :: ICStringLen -> IO ()
- readICStringLen :: HasBinary a StateBinArea => ICStringLen -> IO a
- writeToICStringLen :: HasBinary a StateBinArea => a -> IO ICStringLen
Documentation
data ICStringLen Source #
Instances
UTF8 bytes |
Instances
StringClass (UTF8 ICStringLen) Source # | |
Defined in Util.ICStringLen toString :: UTF8 ICStringLen -> String Source # fromString :: String -> UTF8 ICStringLen Source # fromStringWE :: String -> WithError (UTF8 ICStringLen) Source # |
fromUTF8WE :: (Enum byte, Monad m) => [byte] -> m String Source #
Converts a UTF8 representation of a String back into the String, catching all possible format errors.
Example: With the Haskell module Control.Monad.Error, you can instance this as (fromUTF8WE :: String -> Either String String) to get a conversion function which either succeeds (Right) or returns an error message (Left).
mkICStringLen :: Int -> (CString -> IO ()) -> IO ICStringLen Source #
mkICStringLenExtra :: Int -> (CString -> IO extra) -> IO (ICStringLen, extra) Source #
withICStringLen :: ICStringLen -> (Int -> CString -> IO a) -> IO a Source #
bytesToICStringLen :: (Bytes, Int) -> IO ICStringLen Source #
bytesFromICStringLen :: ICStringLen -> (Bytes, Int) Source #
touchICStringLen :: ICStringLen -> IO () Source #
readICStringLen :: HasBinary a StateBinArea => ICStringLen -> IO a Source #
writeToICStringLen :: HasBinary a StateBinArea => a -> IO ICStringLen Source #