| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Mutable.SRef
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.
- data SRef s a
- type IOSRef = SRef (PrimState IO)
- asSRef :: SRef s a -> SRef 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 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 |
Functions
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
| 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) |