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

Safe HaskellNone
LanguageHaskell2010

Data.Mutable.URef

Contents

Description

Use 1-length mutable unboxed 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 URef s a Source

An unboxed vector reference, supporting any monad.

Instances

Unbox a => MutableRef (URef s a) 
MutableContainer (URef s a) 
type RefElement (URef s a) = a 
type MCState (URef s a) = s 

type IOURef = URef (PrimState IO) Source

An unboxed IO vector reference.

Functions

asURef :: URef s a -> URef 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