Z-Data-0.1.7.2: Array, vector and text

Copyright(c) Dong Han 2017~2019
LicenseBSD-style
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Z.Data.PrimRef.PrimSTRef

Contents

Description

This package provide fast unboxed references for ST monad. Unboxed reference is implemented using single cell MutableByteArray s to eliminate indirection overhead which MutVar# s a carry, on the otherhand unboxed reference only support limited type(instances of Prim class).

Synopsis

Unboxed ST references

newtype PrimSTRef s a Source #

A mutable variable in the ST monad which can hold an instance of Prim.

Constructors

PrimSTRef (MutableByteArray s) 

newPrimSTRef :: Prim a => a -> ST s (PrimSTRef s a) Source #

Build a new PrimSTRef

readPrimSTRef :: Prim a => PrimSTRef s a -> ST s a Source #

Read the value of an PrimSTRef

writePrimSTRef :: Prim a => PrimSTRef s a -> a -> ST s () Source #

Write a new value into an PrimSTRef

modifyPrimSTRef :: Prim a => PrimSTRef s a -> (a -> a) -> ST s () Source #

Mutate the contents of an PrimSTRef.

Unboxed reference is always strict on the value it hold.