proto-lens-0.7.1.3: A lens-based implementation of protocol buffers in Haskell.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ProtoLens.Encoding.Growing

Description

A mutable vector that grows in size.

Example usage:

import qualified Data.ProtoLens.Encoding.Growing as Growing
import qualified Data.Vector.Unboxed as V
test :: IO (V.Vector Int)
test = do
    v <- Growing.new
    v' <- Growing.append v 1
    v'' <- Growing.append v' 2
    v''' <- Growing.append v'' 3
    unsafeFreeze v'''
Synopsis

Documentation

data Growing v s a Source #

A mutable vector which can increase in capacity.

new :: (PrimMonad m, Vector v a) => m (Growing v (PrimState m) a) Source #

Create a new empty growing vector.

append :: (PrimMonad m, Vector v a) => Growing v (PrimState m) a -> a -> m (Growing v (PrimState m) a) Source #

Returns a new growing vector with a new element at the end. Note that the return value may share storage with the input value. Furthermore, calling append twice on the same input may result in two vectors that share the same storage.

unsafeFreeze :: (PrimMonad m, Vector v a) => Growing v (PrimState m) a -> m (v a) Source #

Unsafely convert a growing vector to an immutable one without copying. After this call, you may not use the growing vector nor any other growing vectors that were used to produce this one.

data RealWorld #

RealWorld is deeply magical. It is primitive, but it is not unlifted (hence ptrArg). We never manipulate values of type RealWorld; it's only used in the type system, to parameterise State#.