-- 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.2.0
-- | Various typeclasses for mutable containers.
module Data.Mutable.Class
-- | 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 :: *
type MutableStack c = (MutablePopFront c, MutablePushFront c)
type MutableDeque c = (MutableQueue c, MutablePushFront c, MutablePopBack c)
-- | A mutable variable in the IO monad
data IORef a :: * -> *
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 :: * -> * -> *
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 :: * -> * -> *
asMutVar :: MutVar s a -> MutVar s a
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 => MutablePushFront c
pushFront :: (MutablePushFront c, PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m ()
class MutableCollection c => MutablePushBack c
pushBack :: (MutablePushBack c, PrimMonad m, PrimState m ~ MCState c) => c -> CollElement c -> m ()
class MutableCollection c => MutablePopFront c
popFront :: (MutablePopFront c, PrimMonad m, PrimState m ~ MCState c) => c -> m (Maybe (CollElement c))
class MutableCollection c => MutablePopBack c
popBack :: (MutablePopBack c, PrimMonad m, PrimState m ~ MCState c) => c -> m (Maybe (CollElement c))
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)
-- | Use ByteArrays containing one element for mutable references.
--
-- This is similar to URefs, but avoids the overhead of storing
-- the length of the Vector, which we statically know will
-- always be 1. This allows it to be a bit faster.
--
-- Motivated by:
-- http://stackoverflow.com/questions/27261813/why-is-my-little-stref-int-require-allocating-gigabytes
-- and ArrayRef.
module Data.Mutable.PRef
-- | A primitive ByteArray reference, supporting any monad.
data PRef s a
-- | A primitive ByteArray IO reference.
type IOPRef = PRef (PrimState IO)
asPRef :: PRef s a -> PRef 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 Prim a => MutableRef (PRef s a)
instance MutableContainer (PRef s a)
-- | 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.
module Data.Mutable.VRef
-- | A boxed vector reference, supporting any monad.
data VRef s a
-- | A boxed IO vector reference.
type IOVRef = VRef (PrimState IO)
asVRef :: VRef s a -> VRef 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 MutableRef (VRef s a)
instance MutableContainer (VRef 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
asBDeque :: 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)