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

Safe HaskellNone
LanguageHaskell2010

Data.Mutable.SRef

Contents

Description

Use 1-length mutable storable 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 SRef s a Source

A storable vector reference, supporting any monad.

Instances

Storable a => MutableRef (SRef s a) 
MutableContainer (SRef s a) 
type RefElement (SRef s a) = a 
type MCState (SRef s a) = s 

type IOSRef = SRef (PrimState IO) Source

A storable IO vector reference.

Functions

asSRef :: SRef s a -> SRef 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