Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Builder = Builder (forall s. MutableByteArray# s -> Int# -> Int# -> Commits s -> State# s -> (#State# s, MutableByteArray# s, Int#, Int#, Commits s#))
- data BuilderState s = BuilderState (MutableByteArray# s) Int# Int# !(Commits s)
- data Commits s
- = Mutable (MutableByteArray# s) Int# !(Commits s)
- | Immutable ByteArray# Int# Int# !(Commits s)
- | Initial
- pasteST :: Builder -> BuilderState s -> ST s (BuilderState s)
- pasteIO :: Builder -> BuilderState RealWorld -> IO (BuilderState RealWorld)
- fromEffect :: Int -> (forall s. MutableByteArray s -> Int -> ST s Int) -> Builder
- reverseCommitsOntoChunks :: Chunks -> Commits s -> ST s Chunks
- copyReverseCommits :: MutableByteArray s -> Int -> Commits s -> ST s Int
- addCommitsLength :: Int -> Commits s -> Int
- stringUtf8 :: String -> Builder
- cstring :: CString -> Builder
Types
An unmaterialized sequence of bytes that may be pasted into a mutable byte array.
Builder (forall s. MutableByteArray# s -> Int# -> Int# -> Commits s -> State# s -> (#State# s, MutableByteArray# s, Int#, Int#, Commits s#)) |
data BuilderState s Source #
BuilderState (MutableByteArray# s) Int# Int# !(Commits s) |
Mutable | |
| |
Immutable | |
| |
Initial |
Execution
pasteST :: Builder -> BuilderState s -> ST s (BuilderState s) Source #
Run a builder, performing an in-place update on the state.
The BuilderState
argument must not be reused after being passed
to this function. That is, its use must be affine.
pasteIO :: Builder -> BuilderState RealWorld -> IO (BuilderState RealWorld) Source #
Construction
Finalization
reverseCommitsOntoChunks :: Chunks -> Commits s -> ST s Chunks Source #
Cons the chunks from a list of Commits
onto an initial
Chunks
list (this argument is often ChunksNil
). This reverses
the order of the chunks, which is desirable since builders assemble
Commits
with the chunks backwards. This performs an in-place shrink
and freezes on any mutable byte arrays it encounters. Consequently,
these must not be reused.
:: MutableByteArray s | Destination |
-> Int | Destination range successor |
-> Commits s | Source |
-> ST s Int |
Copy the contents of the chunks into a mutable array, reversing the order of the chunks. Precondition: The destination must have enough space to house the contents. This is not checked.
addCommitsLength :: Int -> Commits s -> Int Source #
Add the total number of bytes in the commits to first argument.
Safe Functions
These functions are actually completely safe, but they are defined
here because they are used by typeclass instances. Import them from
Data.ByteArray.Builder
instead.