| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Mikan.Utils.ShortText
Description
Utilities for working with ShortText
This module is meant to be imported qualified as
import Mikan.Utils.ShortText qualified as TS
Synopsis
- unsafeCreate :: Int -> (forall s. MutableByteArray s -> ST s ()) -> ShortText
- lengthBytes :: ShortText -> Int
- unwords :: [ShortText] -> ShortText
- toByteArray :: ShortText -> ByteArray
- unsafeFromByteArray :: ByteArray -> ShortText
- copyBytes :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> ShortText -> Int -> Int -> m ()
Creation
unsafeCreate :: Int -> (forall s. MutableByteArray s -> ST s ()) -> ShortText Source #
\(\mathcal{O}(1)\). Create a ShortText from a newly allocated MutableByteArray
of length n.
The caller is responsible for ensuring that the MutableByteArray is filled with
valid UTF-8 encoded text.
Length
Breaking into lines and words
Conversion
toByteArray :: ShortText -> ByteArray Source #
Arguments
| :: PrimMonad m | |
| => MutableByteArray (PrimState m) | Destination buffer. |
| -> Int | Offset into the destination buffer, measured in bytes. |
| -> ShortText | Source |
| -> Int | Offset into the |
| -> Int | How many bytes to copy |
| -> m () |
\(\mathcal{O}(n)\). Copy bytes from a ShortText into a MutableByteArray.