-- 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.1.0.0 -- | Various typeclasses for mutable containers. module Data.Mutable.Class class MutableContainer c where type family MCState c 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 () 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 class MutableContainer c => MutableCollection c where type family CollElement c newColl :: (MutableCollection c, PrimMonad m, PrimState m ~ MCState c) => m c class MutableCollection c => MutablePopFront c popFront :: (MutablePopFront c, PrimMonad m, PrimState m ~ MCState c) => c -> m (Maybe (CollElement c)) popFrontRef :: (PrimMonad m, PrimState m ~ MCState c, MutableRef c, CollElement c ~ Element (RefElement c), IsSequence (RefElement c)) => c -> m (Maybe (CollElement c)) class MutableCollection c => MutablePushFront c pushFront :: (MutablePushFront c, PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m () pushFrontRef :: (PrimMonad m, PrimState m ~ MCState c, MutableRef c, CollElement c ~ Element (RefElement c), IsSequence (RefElement c)) => c -> CollElement c -> m () class MutableCollection c => MutablePopBack c popBack :: (MutablePopBack c, PrimMonad m, PrimState m ~ MCState c) => c -> m (Maybe (CollElement c)) popBackRef :: (PrimMonad m, PrimState m ~ MCState c, MutableRef c, CollElement c ~ Element (RefElement c), IsSequence (RefElement c)) => c -> m (Maybe (CollElement c)) class MutableCollection c => MutablePushBack c pushBack :: (MutablePushBack c, PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m () pushBackRef :: (PrimMonad m, PrimState m ~ MCState c, MutableRef c, CollElement c ~ Element (RefElement c), IsSequence (RefElement c)) => c -> CollElement c -> m () type MutableQueue c = (MutablePopFront c, MutablePushBack c) type MutableStack c = (MutablePopFront c, MutablePushFront c) type MutableDeque c = (MutableQueue c, MutablePushFront c, MutablePopBack c) asIORef :: IORef a -> IORef a asSTRef :: STRef s a -> STRef s a asMutVar :: MutVar s a -> MutVar s a instance IsSequence a => MutablePushBack (MutVar s a) instance IsSequence a => MutablePushBack (STRef s a) instance IsSequence a => MutablePushBack (IORef a) instance IsSequence a => MutablePopBack (MutVar s a) instance IsSequence a => MutablePopBack (STRef s a) instance IsSequence a => MutablePopBack (IORef a) instance IsSequence a => MutablePushFront (MutVar s a) instance IsSequence a => MutablePushFront (STRef s a) instance IsSequence a => MutablePushFront (IORef a) instance IsSequence a => MutablePopFront (MutVar s a) instance IsSequence a => MutablePopFront (STRef s a) instance IsSequence a => MutablePopFront (IORef a) instance Monoid w => MutableCollection (MutVar s w) instance Monoid w => MutableCollection (STRef s w) instance Monoid w => MutableCollection (IORef w) instance MutableAtomicRef (MutVar s a) instance MutableAtomicRef (IORef a) instance MutableRef (MutVar s a) instance MutableRef (STRef s a) instance MutableRef (IORef a) instance MutableContainer (MutVar s a) instance MutableContainer (STRef s a) instance MutableContainer (IORef a) -- | Use 1-length mutable unboxed vectors for mutable references. -- -- Motivated by: -- http://stackoverflow.com/questions/27261813/why-is-my-little-stref-int-require-allocating-gigabytes -- and ArrayRef. module Data.Mutable.URef -- | An unboxed vector reference, supporting any monad. data URef s a -- | An unboxed IO vector reference. type IOURef = URef (PrimState IO) asURef :: URef s a -> URef s a 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 () instance Unbox a => MutableRef (URef s a) instance MutableContainer (URef s a) -- | Doubly-linked list module Data.Mutable.DList data DList s a asDList :: DList s a -> DList s a instance MutablePushBack (DList s a) instance MutablePushFront (DList s a) instance MutablePopBack (DList s a) instance MutablePopFront (DList s a) instance MutableCollection (DList s a) instance MutableContainer (DList s a) module Data.Mutable.Deque data Deque v s a asUDeque :: Deque MVector s a -> Deque MVector s a asSDeque :: Deque MVector s a -> Deque MVector s a instance MVector v a => MutablePushBack (Deque v s a) instance MVector v a => MutablePushFront (Deque v s a) instance MVector v a => MutablePopBack (Deque v s a) instance MVector v a => MutablePopFront (Deque v s a) instance MVector v a => MutableCollection (Deque v s a) instance MutableContainer (Deque v s a) -- | 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. module Data.Mutable.SRef -- | A storable vector reference, supporting any monad. data SRef s a -- | A storable IO vector reference. type IOSRef = SRef (PrimState IO) asSRef :: SRef s a -> SRef s a 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 () instance Storable a => MutableRef (SRef s a) instance MutableContainer (SRef s a)