-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Double-ended queues -- -- Strict and lazy implementations of Double-Ended Queue (aka Dequeue or -- Deque) based on head-tail linked list. @package deque @version 0.3 -- | Definitions of lazy Deque. -- -- The typical toList and fromList conversions are provided -- by means of the Foldable and IsList instances. module Deque.Lazy -- | Lazy double-ended queue (aka Dequeue or Deque) based on head-tail -- linked list. data Deque a -- | O(1). Construct from cons and snoc lists. fromConsAndSnocLists :: [a] -> [a] -> Deque a -- | O(1). Add element in the beginning. cons :: a -> Deque a -> Deque a -- | O(1). Add element in the ending. snoc :: a -> Deque a -> Deque a -- | O(1). Revert the deque. reverse :: Deque a -> Deque a -- | O(1), occasionally O(n). Move the first element to the -- end. -- --
--   λ toList . shiftLeft $ fromList [1,2,3]
--   [2,3,1]
--   
shiftLeft :: Deque a -> Deque a -- | O(1), occasionally O(n). Move the last element to the -- beginning. -- --
--   λ toList . shiftRight $ fromList [1,2,3]
--   [3,1,2]
--   
shiftRight :: Deque a -> Deque a -- | O(n). Leave only the elements satisfying the predicate. filter :: (a -> Bool) -> Deque a -> Deque a -- | O(n). Leave only the first elements satisfying the predicate. takeWhile :: (a -> Bool) -> Deque a -> Deque a -- | O(n). Drop the first elements satisfying the predicate. dropWhile :: (a -> Bool) -> Deque a -> Deque a -- | O(1), occasionally O(n). Get the first element and deque -- without it if it's not empty. uncons :: Deque a -> Maybe (a, Deque a) -- | O(1), occasionally O(n). Get the last element and deque -- without it if it's not empty. unsnoc :: Deque a -> Maybe (a, Deque a) -- | O(1). Check whether deque is empty. null :: Deque a -> Bool -- | O(1), occasionally O(n). Get the first element if deque -- is not empty. head :: Deque a -> Maybe a -- | O(1), occasionally O(n). Get the last element if deque -- is not empty. last :: Deque a -> Maybe a -- | O(1), occasionally O(n). Keep all elements but the first -- one. -- -- In case of empty deque returns an empty deque. tail :: Deque a -> Deque a -- | O(1), occasionally O(n). Keep all elements but the last -- one. -- -- In case of empty deque returns an empty deque. init :: Deque a -> Deque a instance GHC.Base.Functor Deque.Lazy.Deque instance GHC.Classes.Eq a => GHC.Classes.Eq (Deque.Lazy.Deque a) instance GHC.Show.Show a => GHC.Show.Show (Deque.Lazy.Deque a) instance GHC.Base.Semigroup (Deque.Lazy.Deque a) instance GHC.Base.Monoid (Deque.Lazy.Deque a) instance Data.Foldable.Foldable Deque.Lazy.Deque instance Data.Traversable.Traversable Deque.Lazy.Deque instance GHC.Base.Applicative Deque.Lazy.Deque instance GHC.Base.Monad Deque.Lazy.Deque instance GHC.Base.Alternative Deque.Lazy.Deque instance GHC.Base.MonadPlus Deque.Lazy.Deque instance Control.Monad.Fail.MonadFail Deque.Lazy.Deque instance GHC.Exts.IsList (Deque.Lazy.Deque a) -- | Lazy Deque API lifted to a State monad, "mtl"-style. module Deque.Lazy.State -- | O(1). Add element in the beginning. cons :: MonadState (Deque a) m => a -> m () -- | O(1). Add element in the ending. snoc :: MonadState (Deque a) m => a -> m () -- | O(1). Revert the deque. reverse :: MonadState (Deque a) m => m () -- | O(1), occasionally O(n). Move the first element to the -- end. shiftLeft :: MonadState (Deque a) m => m () -- | O(1), occasionally O(n). Move the last element to the -- beginning. shiftRight :: MonadState (Deque a) m => m () -- | O(n). Leave only the elements satisfying the predicate. filter :: MonadState (Deque a) m => (a -> Bool) -> m () -- | O(n). Leave only the first elements satisfying the predicate. takeWhile :: MonadState (Deque a) m => (a -> Bool) -> m () -- | O(n). Drop the first elements satisfying the predicate. dropWhile :: MonadState (Deque a) m => (a -> Bool) -> m () -- | O(1), occasionally O(n). Get the first element and deque -- without it if it's not empty. uncons :: MonadState (Deque a) m => m (Maybe a) -- | O(1), occasionally O(n). Get the last element and deque -- without it if it's not empty. unsnoc :: MonadState (Deque a) m => m (Maybe a) -- | O(1). Check whether deque is empty. null :: MonadState (Deque a) m => m Bool -- | O(1). Check whether deque is empty. length :: MonadState (Deque a) m => m Int -- | O(1), occasionally O(n). Get the first element if deque -- is not empty. head :: MonadState (Deque a) m => m (Maybe a) -- | O(1), occasionally O(n). Get the last element if deque -- is not empty. last :: MonadState (Deque a) m => m (Maybe a) -- | O(1), occasionally O(n). Keep all elements but the first -- one. -- -- In case of empty deque returns an empty deque. tail :: MonadState (Deque a) m => m (Deque a) -- | O(1), occasionally O(n). Keep all elements but the last -- one. -- -- In case of empty deque returns an empty deque. init :: MonadState (Deque a) m => m (Deque a) -- | Definitions of strict Deque. -- -- The typical toList and fromList conversions are provided -- by means of the Foldable and IsList instances. module Deque.Strict -- | Strict double-ended queue (aka Dequeue or Deque) based on head-tail -- linked list. data Deque a -- | O(1). Construct from cons and snoc lists. fromConsAndSnocLists :: [a] -> [a] -> Deque a -- | O(1). Add element in the beginning. cons :: a -> Deque a -> Deque a -- | O(1). Add element in the ending. snoc :: a -> Deque a -> Deque a -- | O(1). Revert the deque. reverse :: Deque a -> Deque a -- | O(1), occasionally O(n). Move the first element to the -- end. -- --
--   λ toList . shiftLeft $ fromList [1,2,3]
--   [2,3,1]
--   
shiftLeft :: Deque a -> Deque a -- | O(1), occasionally O(n). Move the last element to the -- beginning. -- --
--   λ toList . shiftRight $ fromList [1,2,3]
--   [3,1,2]
--   
shiftRight :: Deque a -> Deque a -- | O(n). Leave only the elements satisfying the predicate. filter :: (a -> Bool) -> Deque a -> Deque a -- | O(n). Leave only the first elements satisfying the predicate. takeWhile :: (a -> Bool) -> Deque a -> Deque a -- | O(n). Drop the first elements satisfying the predicate. dropWhile :: (a -> Bool) -> Deque a -> Deque a -- | O(1), occasionally O(n). Get the first element and deque -- without it if it's not empty. uncons :: Deque a -> Maybe (a, Deque a) -- | O(1), occasionally O(n). Get the last element and deque -- without it if it's not empty. unsnoc :: Deque a -> Maybe (a, Deque a) -- | O(1). Check whether deque is empty. null :: Deque a -> Bool -- | O(1), occasionally O(n). Get the first element if deque -- is not empty. head :: Deque a -> Maybe a -- | O(1), occasionally O(n). Get the last element if deque -- is not empty. last :: Deque a -> Maybe a -- | O(1), occasionally O(n). Keep all elements but the first -- one. -- -- In case of empty deque returns an empty deque. tail :: Deque a -> Deque a -- | O(1), occasionally O(n). Keep all elements but the last -- one. -- -- In case of empty deque returns an empty deque. init :: Deque a -> Deque a instance GHC.Base.Functor Deque.Strict.Deque instance GHC.Classes.Eq a => GHC.Classes.Eq (Deque.Strict.Deque a) instance GHC.Show.Show a => GHC.Show.Show (Deque.Strict.Deque a) instance GHC.Exts.IsList (Deque.Strict.Deque a) instance GHC.Base.Semigroup (Deque.Strict.Deque a) instance GHC.Base.Monoid (Deque.Strict.Deque a) instance Data.Foldable.Foldable Deque.Strict.Deque instance Data.Traversable.Traversable Deque.Strict.Deque instance GHC.Base.Applicative Deque.Strict.Deque instance GHC.Base.Monad Deque.Strict.Deque instance GHC.Base.Alternative Deque.Strict.Deque instance GHC.Base.MonadPlus Deque.Strict.Deque instance Control.Monad.Fail.MonadFail Deque.Strict.Deque -- | Strict Deque API lifted to a State monad, "mtl"-style. module Deque.Strict.State -- | O(1). Add element in the beginning. cons :: MonadState (Deque a) m => a -> m () -- | O(1). Add element in the ending. snoc :: MonadState (Deque a) m => a -> m () -- | O(1). Revert the deque. reverse :: MonadState (Deque a) m => m () -- | O(1), occasionally O(n). Move the first element to the -- end. shiftLeft :: MonadState (Deque a) m => m () -- | O(1), occasionally O(n). Move the last element to the -- beginning. shiftRight :: MonadState (Deque a) m => m () -- | O(n). Leave only the elements satisfying the predicate. filter :: MonadState (Deque a) m => (a -> Bool) -> m () -- | O(n). Leave only the first elements satisfying the predicate. takeWhile :: MonadState (Deque a) m => (a -> Bool) -> m () -- | O(n). Drop the first elements satisfying the predicate. dropWhile :: MonadState (Deque a) m => (a -> Bool) -> m () -- | O(1), occasionally O(n). Get the first element and deque -- without it if it's not empty. uncons :: MonadState (Deque a) m => m (Maybe a) -- | O(1), occasionally O(n). Get the last element and deque -- without it if it's not empty. unsnoc :: MonadState (Deque a) m => m (Maybe a) -- | O(1). Check whether deque is empty. null :: MonadState (Deque a) m => m Bool -- | O(1). Check whether deque is empty. length :: MonadState (Deque a) m => m Int -- | O(1), occasionally O(n). Get the first element if deque -- is not empty. head :: MonadState (Deque a) m => m (Maybe a) -- | O(1), occasionally O(n). Get the last element if deque -- is not empty. last :: MonadState (Deque a) m => m (Maybe a) -- | O(1), occasionally O(n). Keep all elements but the first -- one. -- -- In case of empty deque returns an empty deque. tail :: MonadState (Deque a) m => m (Deque a) -- | O(1), occasionally O(n). Keep all elements but the last -- one. -- -- In case of empty deque returns an empty deque. init :: MonadState (Deque a) m => m (Deque a)