Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various typeclasses for mutable containers.
- class Monad m => PrimMonad m where
- type PrimState m :: *
- type family PrimState m :: *
- data RealWorld :: *
- type MutableStack c = (MutablePopFront c, MutablePushFront c)
- type MutableDeque c = (MutableQueue c, MutablePushFront c, MutablePopBack c)
- data IORef a :: * -> *
- asIORef :: IORef a -> IORef a
- data STRef s a :: * -> * -> *
- asSTRef :: STRef s a -> STRef s a
- data MutVar s a :: * -> * -> *
- asMutVar :: MutVar s a -> MutVar s a
- class MutableContainer c where
- type MCState c
- 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 ()
- class MutableRef c => MutableAtomicRef c where
- atomicModifyRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> (RefElement c, a)) -> m a
- atomicModifyRef' :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> (RefElement c, a)) -> m a
- class MutableContainer c => MutableCollection c where
- type CollElement c
- newColl :: (PrimMonad m, PrimState m ~ MCState c) => m c
- class MutableCollection c => MutablePushFront c where
- pushFront :: (PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m ()
- class MutableCollection c => MutablePushBack c where
- pushBack :: (PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m ()
- class MutableCollection c => MutablePopFront c where
- class MutableCollection c => MutablePopBack c where
Documentation
Class of primitive state-transformer monads
type PrimState m :: *
State token type
data RealWorld :: *
RealWorld
is deeply magical. It is primitive, but it is not
unlifted (hence ptrArg
). We never manipulate values of type
RealWorld
; it's only used in the type system, to parameterise State#
.
type MutableStack c = (MutablePopFront c, MutablePushFront c) Source
type MutableDeque c = (MutableQueue c, MutablePushFront c, MutablePopBack c) Source
data IORef a :: * -> *
A mutable variable in the IO
monad
Eq (IORef a) | |
IsSequence a => MutablePushBack (IORef a) | |
IsSequence a => MutablePopBack (IORef a) | |
IsSequence a => MutablePushFront (IORef a) | |
IsSequence a => MutablePopFront (IORef a) | |
Monoid w => MutableCollection (IORef w) | |
MutableAtomicRef (IORef a) | |
MutableRef (IORef a) | |
MutableContainer (IORef a) | |
Typeable (* -> *) IORef | |
type CollElement (IORef w) = Element w | |
type RefElement (IORef a) = a | |
type MCState (IORef a) = PrimState IO |
data STRef s a :: * -> * -> *
a value of type STRef s a
is a mutable variable in state thread s
,
containing a value of type a
Eq (STRef s a) | |
IsSequence a => MutablePushBack (STRef s a) | |
IsSequence a => MutablePopBack (STRef s a) | |
IsSequence a => MutablePushFront (STRef s a) | |
IsSequence a => MutablePopFront (STRef s a) | |
Monoid w => MutableCollection (STRef s w) | |
MutableRef (STRef s a) | |
MutableContainer (STRef s a) | |
type CollElement (STRef s w) = Element w | |
type RefElement (STRef s a) = a | |
type MCState (STRef s a) = s |
data MutVar s a :: * -> * -> *
A MutVar
behaves like a single-element mutable array associated
with a primitive state token.
Eq (MutVar s a) | |
IsSequence a => MutablePushBack (MutVar s a) | |
IsSequence a => MutablePopBack (MutVar s a) | |
IsSequence a => MutablePushFront (MutVar s a) | |
IsSequence a => MutablePopFront (MutVar s a) | |
Monoid w => MutableCollection (MutVar s w) | |
MutableAtomicRef (MutVar s a) | |
MutableRef (MutVar s a) | |
MutableContainer (MutVar s a) | |
Typeable (* -> * -> *) MutVar | |
type CollElement (MutVar s w) = Element w | |
type RefElement (MutVar s a) = a | |
type MCState (MutVar s a) = s |
class MutableContainer c Source
MutableContainer (IORef a) | |
MutableContainer (STRef s a) | |
MutableContainer (MutVar s a) | |
MutableContainer (URef s a) | |
MutableContainer (PRef s a) | |
MutableContainer (VRef s a) | |
MutableContainer (DList s a) | |
MutableContainer (SRef s a) | |
MutableContainer (Deque v s a) |
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) | |
Prim a => MutableRef (PRef s a) | |
MutableRef (VRef s a) | |
Storable a => MutableRef (SRef s a) |
class MutableRef c => MutableAtomicRef c where Source
atomicModifyRef :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> (RefElement c, a)) -> m a Source
atomicModifyRef' :: (PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> (RefElement c, a)) -> m a Source
MutableAtomicRef (IORef a) | |
MutableAtomicRef (MutVar s a) |
class MutableContainer c => MutableCollection c where Source
type CollElement c Source
Monoid w => MutableCollection (IORef w) | |
Monoid w => MutableCollection (STRef s w) | |
Monoid w => MutableCollection (MutVar s w) | |
MutableCollection (DList s a) | |
MVector v a => MutableCollection (Deque v s a) |
class MutableCollection c => MutablePushFront c where Source
IsSequence a => MutablePushFront (IORef a) | |
IsSequence a => MutablePushFront (STRef s a) | |
IsSequence a => MutablePushFront (MutVar s a) | |
MutablePushFront (DList s a) | |
MVector v a => MutablePushFront (Deque v s a) |
class MutableCollection c => MutablePushBack c where Source
IsSequence a => MutablePushBack (IORef a) | |
IsSequence a => MutablePushBack (STRef s a) | |
IsSequence a => MutablePushBack (MutVar s a) | |
MutablePushBack (DList s a) | |
MVector v a => MutablePushBack (Deque v s a) |
class MutableCollection c => MutablePopFront c where Source
IsSequence a => MutablePopFront (IORef a) | |
IsSequence a => MutablePopFront (STRef s a) | |
IsSequence a => MutablePopFront (MutVar s a) | |
MutablePopFront (DList s a) | |
MVector v a => MutablePopFront (Deque v s a) |
class MutableCollection c => MutablePopBack c where Source
IsSequence a => MutablePopBack (IORef a) | |
IsSequence a => MutablePopBack (STRef s a) | |
IsSequence a => MutablePopBack (MutVar s a) | |
MutablePopBack (DList s a) | |
MVector v a => MutablePopBack (Deque v s a) |