mutable-containers-0.1.1.0: Abstactions and concrete implementations of mutable containers

Safe HaskellNone
LanguageHaskell2010

Data.Mutable.VRef

Contents

Description

Use 1-length mutable boxed vectors for mutable references.

Motivated by: http://stackoverflow.com/questions/27261813/why-is-my-little-stref-int-require-allocating-gigabytes and ArrayRef.

Synopsis

Types

data VRef s a Source

A boxed vector reference, supporting any monad.

Instances

MutableRef (VRef s a) 
MutableContainer (VRef s a) 
type RefElement (VRef s a) = a 
type MCState (VRef s a) = s 

type IOVRef = VRef (PrimState IO) Source

A boxed IO vector reference.

Functions

asVRef :: VRef s a -> VRef s a Source

class MutableContainer c => MutableRef c where Source

Associated Types

type RefElement c Source

Methods

newRef :: (PrimMonad m, PrimState m ~ MCState c) => RefElement c -> m c Source

readRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> m (RefElement c) Source

writeRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> RefElement c -> m () Source

modifyRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> RefElement c) -> m () Source

modifyRef' :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> RefElement c) -> m () Source

Instances