basement-0.0.16: Foundation scrap box of array & string

License | BSD-style
Maintainer | Foundation
Safe Haskell | None
Language | Haskell2010

Basement.Block.Builder

Contents

- Emit functions
- unsafe

Description

Block builder

Synopsis

- data Builder
- run :: PrimMonad prim => Builder -> prim (Block Word8)
- emit :: Block a -> Builder
- emitPrim :: (PrimType ty, ty ~ Word8) => ty -> Builder
- emitString :: String -> Builder
- emitUTF8Char :: Char -> Builder
- unsafeRunString :: PrimMonad prim => Builder -> prim String

# Documentation

data Builder Source #

#### Instances

Instances details

Monoid Builder Source # |
Instance details Defined in Basement.Block.Builder Methods mempty :: Builder Source # mappend :: Builder -> Builder -> Builder Source # mconcat :: [Builder] -> Builder Source #
Semigroup Builder Source # |
Instance details Defined in Basement.Block.Builder Methods (<>) :: Builder -> Builder -> Builder Source # sconcat :: NonEmpty Builder -> Builder Source # stimes :: Integral b => b -> Builder -> Builder Source #

run :: PrimMonad prim => Builder -> prim (Block Word8) Source #

run the given builder and return the generated block

# Emit functions

emit :: Block a -> Builder Source #

add a Block in the builder

emitPrim :: (PrimType ty, ty ~ Word8) => ty -> Builder Source #

emitString :: String -> Builder Source #

add a string in the builder

emitUTF8Char :: Char -> Builder Source #

emit a UTF8 char in the builder

this function may be replaced by `emit :: Encoding -> Char -> Builder`

# unsafe

unsafeRunString :: PrimMonad prim => Builder -> prim String Source #

run the given builder and return a UTF8String

this action is unsafe as there is no guarantee upon the validity of the content of the built block.