Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- data VRef s a
- type IOVRef = VRef (PrimState IO)
- asVRef :: VRef s a -> VRef s a
- class MutableContainer c => MutableRef c where
- type RefElement c
- newRef :: (PrimMonad m, PrimState m ~ MCState c) => RefElement c -> m c
- readRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> m (RefElement c)
- writeRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> RefElement c -> m ()
- modifyRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> RefElement c) -> m ()
- modifyRef' :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> RefElement c) -> m ()
Types
A boxed vector reference, supporting any monad.
MutableRef (VRef s a) | |
MutableContainer (VRef s a) | |
type RefElement (VRef s a) = a | |
type MCState (VRef s a) = s |
Functions
class MutableContainer c => MutableRef c where Source
type RefElement c Source
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
MutableRef (IORef a) | |
MutableRef (STRef s a) | |
MutableRef (MutVar s a) | |
Unbox a => MutableRef (URef s a) | |
MutableRef (VRef s a) | |
Storable a => MutableRef (SRef s a) |