Community
Modules 11

System.OsString.Data.ByteString.Short.Internal

experimental

Internal low-level utilities mostly for Word16, such as byte-array operations and other stuff not meant to be exported from Word16 module.

create :: Int -> (forall s. MBA s -> ST s ()) -> ShortByteString

asBA :: ShortByteString -> BA

data BA

BA# :: ByteArray# -> BA

data MBA s

MBA# :: (MutableByteArray# s) -> MBA s

packCWString :: Ptr Word16 -> IO ShortByteString

O(n). Construct a new ShortByteString from a CWString. The resulting ShortByteString is an immutable copy of the original CWString, and is managed on the Haskell heap. The original CWString must be null terminated.

packCWStringLen :: (Ptr Word16, Int) -> IO ShortByteString

O(n). Construct a new ShortByteString from a CWStringLen. The resulting ShortByteString is an immutable copy of the original CWStringLen. The ShortByteString is a normal Haskell value and will be managed on the Haskell heap.

useAsCWString :: ShortByteString -> (Ptr Word16 -> IO a) -> IO a

O(n) construction. Use a ShortByteString with a function requiring a null-terminated CWString. The CWString is a copy and will be freed automatically; it must not be stored or used after the subcomputation finishes.

useAsCWStringLen :: ShortByteString -> ((Ptr Word16, Int) -> IO a) -> IO a

O(n) construction. Use a ShortByteString with a function requiring a CWStringLen. As for useAsCWString this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.

newCWString :: ShortByteString -> IO (Ptr Word16)

O(n) construction. Use a ShortByteString with a function requiring a CWStringLen. As for useAsCWString this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.

writeWord16Array :: MBA s -> Int -> Word16 -> ST s ()

Encode Word16 as little-endian.

Int

Word8 index (not Word16)

indexWord16Array :: BA -> Int -> Word16

Decode Word16 from little-endian.

Int

Word8 index (not Word16)

createAndTrim :: Int -> (forall s. MBA s -> ST s (Int, a)) -> (ShortByteString, a)

Given the maximum size needed and a function to make the contents of a ShortByteString, createAndTrim makes the ShortByteString. The generating function is required to return the actual final size (<= the maximum size) and the result value. The resulting byte array is realloced to this size.

createAndTrim' :: Int -> (forall s. MBA s -> ST s Int) -> ShortByteString

createAndTrim'' :: Int -> (forall s. MBA s -> MBA s -> ST s (Int, Int)) -> (ShortByteString, ShortByteString)

findFromEndUntil :: (Word16 -> Bool) -> ShortByteString -> Int

Returns the length of the substring matching, not the index. If no match, returns 0.

assertEven :: ShortByteString -> ShortByteString

compareByteArraysOff :: BA -> Int -> BA -> Int -> Int -> Int

BA

array 1

Int

offset for array 1

BA

array 2

Int

offset for array 2

Int

length to compare

Int

like memcmp

Maintainer
Julian Ospald <hasufell@posteo.de>
Portability
portable
Copyright
© 2022 Julian Ospald
License
MIT
Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 4 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-858b1951-web-1

Metadata snapshot: 467adfa4e90b59b0072712e32d97437632176e89f16e62151dd53a2e41646abb

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.