array-builder-0.1.0.0: Builders for arrays

Safe HaskellNone
LanguageHaskell2010

Data.Builder.ST

Synopsis

Documentation

data Builder s a Source #

Builder for an array of boxed elements. This type is appropriate when constructing an array of unknown size in an effectful (ST or IO) setting. In a non-effectful setting, consider the Builder from Data.Builder instead.

A Builder must be used linearly. The type system does not enforce this, so users must be careful when handling a Builder.

Constructors

Builder !(SmallMutableArray s a) !Int !Int !(Chunks a) 

new :: ST s (Builder s a) Source #

Create a new Builder with no elements in it.

push Source #

Arguments

:: a

Element to push onto the end

-> Builder s a

Builder, do not reuse this after pushing onto it

-> ST s (Builder s a)

New builder

Push an element onto the end of the builder. This is not strict in the element, so force it before pushing it on to the builder if doing so is needed to prevent space leaks.

freeze Source #

Arguments

:: Builder s a

Builder, do not reuse after freezing

-> ST s (Chunks a) 

Convert a Builder to Chunks. The Builder must not be reused after this operation.