-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Abstactions and concrete implementations of mutable containers -- -- See docs and README at -- http://www.stackage.org/package/mutable-containers @package mutable-containers @version 0.2.0 -- | Classes and concrete implementations for mutable data structures. -- -- For more information on the design of this library, see the README -- file, also available at -- http://www.stackage.org/package/mutable-containers. module Data.Mutable -- | A primitive ByteArray reference, supporting any monad. -- -- Since 0.2.0 data PRef s a -- | Since 0.2.0 asPRef :: PRef s a -> PRef s a -- | An unboxed vector reference, supporting any monad. -- -- Since 0.2.0 data URef s a -- | Since 0.2.0 asURef :: URef s a -> URef s a -- | A storable vector reference, supporting any monad. -- -- Since 0.2.0 data SRef s a -- | Since 0.2.0 asSRef :: SRef s a -> SRef s a -- | A boxed vector reference, supporting any monad. -- -- Since 0.2.0 data BRef s a -- | Since 0.2.0 asBRef :: BRef s a -> BRef s a -- | A mutable variable in the IO monad data IORef a :: * -> * -- | Since 0.2.0 asIORef :: IORef a -> IORef a -- | a value of type STRef s a is a mutable variable in state -- thread s, containing a value of type a data STRef s a :: * -> * -> * -- | Since 0.2.0 asSTRef :: STRef s a -> STRef s a -- | A MutVar behaves like a single-element mutable array associated -- with a primitive state token. data MutVar s a :: * -> * -> * -- | Since 0.2.0 asMutVar :: MutVar s a -> MutVar s a -- | A double-ended queue supporting any underlying vector type and any -- monad. -- -- This implements a circular double-ended queue with exponential growth. -- -- Since 0.2.0 data Deque v s a -- | A Deque specialized to unboxed vectors. -- -- Since 0.2.0 type UDeque = Deque MVector -- | Since 0.2.0 asUDeque :: UDeque s a -> UDeque s a -- | A Deque specialized to storable vectors. -- -- Since 0.2.0 type SDeque = Deque MVector -- | Since 0.2.0 asSDeque :: SDeque s a -> SDeque s a -- | A Deque specialized to boxed vectors. -- -- Since 0.2.0 type BDeque = Deque MVector -- | Since 0.2.0 asBDeque :: BDeque s a -> BDeque s a -- | A doubly-linked list. -- -- Since 0.2.0 data DList s a -- | Since 0.2.0 asDList :: DList s a -> DList s a -- | The parent typeclass for all mutable containers. -- -- Since 0.2.0 class MutableContainer c where type family MCState c -- | Typeclass for single-cell mutable references. -- -- Since 0.2.0 class MutableContainer c => MutableRef c where type family RefElement c newRef :: (MutableRef c, PrimMonad m, PrimState m ~ MCState c) => RefElement c -> m c readRef :: (MutableRef c, PrimMonad m, PrimState m ~ MCState c) => c -> m (RefElement c) writeRef :: (MutableRef c, PrimMonad m, PrimState m ~ MCState c) => c -> RefElement c -> m () modifyRef :: (MutableRef c, PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> RefElement c) -> m () modifyRef' :: (MutableRef c, PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> RefElement c) -> m () -- | MutableRefs that provide for atomic modifications of their -- contents. -- -- Since 0.2.0 class MutableRef c => MutableAtomicRef c atomicModifyRef :: (MutableAtomicRef c, PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> (RefElement c, a)) -> m a atomicModifyRef' :: (MutableAtomicRef c, PrimMonad m, PrimState m ~ MCState c) => c -> (RefElement c -> (RefElement c, a)) -> m a -- | Containers which contain 0 or more values. -- -- Since 0.2.0 class MutableContainer c => MutableCollection c where type family CollElement c newColl :: (MutableCollection c, PrimMonad m, PrimState m ~ MCState c) => m c -- | Place a value at the front of the collection. -- -- Since 0.2.0 class MutableCollection c => MutablePushFront c pushFront :: (MutablePushFront c, PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m () -- | Place a value at the back of the collection. -- -- Since 0.2.0 class MutableCollection c => MutablePushBack c pushBack :: (MutablePushBack c, PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m () -- | Take a value from the front of the collection, if available. -- -- Since 0.2.0 class MutableCollection c => MutablePopFront c popFront :: (MutablePopFront c, PrimMonad m, PrimState m ~ MCState c) => c -> m (Maybe (CollElement c)) -- | Take a value from the back of the collection, if available. -- -- Since 0.2.0 class MutableCollection c => MutablePopBack c popBack :: (MutablePopBack c, PrimMonad m, PrimState m ~ MCState c) => c -> m (Maybe (CollElement c)) -- | Collections which allow pushing and popping at the front (aka FIFOs). -- -- Since 0.2.0 type MutableQueue c = (MutablePopFront c, MutablePushBack c) -- | Collections which allow pushing at the back and popping at the front -- (aka FILOs). -- -- Since 0.2.0 type MutableStack c = (MutablePopFront c, MutablePushFront c) -- | Collections which allow pushing and popping at the front and back. -- -- Since 0.2.0 type MutableDeque c = (MutableQueue c, MutablePushFront c, MutablePopBack c) -- | Class of primitive state-transformer monads class Monad m => PrimMonad (m :: * -> *) where type family PrimState (m :: * -> *) :: * -- | State token type -- | 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#. data RealWorld :: *