HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduledeque-0.4.4.1Haskell2010

Deque.Lazy

Definitions of lazy Deque.

The typical toList and fromList conversions are provided by means of the Foldable and IsList instances.

  • 1 type
  • 21 values
  • Packagedeque-0.4.4.1
  • Exports22
  • LanguageHaskell2010
  • LicenceMIT
  • SourceLazy.hs
datadata Deque a
#

Lazy double-ended queue (aka Dequeue or Deque) based on head-tail linked list.

Instances21Monad, Functor, MonadFail, Applicative, Foldable, Traversable, …
valuecons :: a -> Deque a -> Deque a
#

\mathcal{O}(1). Add element in the beginning.

valuesnoc :: a -> Deque a -> Deque a
#

\mathcal{O}(1). Add element in the ending.

valueshiftLeft :: Deque a -> Deque a
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Move the first element to the end.

λ toList . shiftLeft $ fromList [1,2,3]
[2,3,1]
valueshiftRight :: Deque a -> Deque a
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Move the last element to the beginning.

λ toList . shiftRight $ fromList [1,2,3]
[3,1,2]
valuefilter :: (a -> Bool) -> Deque a -> Deque a
#

\mathcal{O}(n). Leave only the elements satisfying the predicate.

valuetake :: Int -> Deque a -> Deque a
#

\mathcal{O}(n). Leave only the specified amount of first elements.

valuedrop :: Int -> Deque a -> Deque a
#

\mathcal{O}(n). Drop the specified amount of first elements.

valuetakeWhile :: (a -> Bool) -> Deque a -> Deque a
#

\mathcal{O}(n). Leave only the first elements satisfying the predicate.

valuedropWhile :: (a -> Bool) -> Deque a -> Deque a
#

\mathcal{O}(n). Drop the first elements satisfying the predicate.

valueuncons :: Deque a -> Maybe (a, Deque a)
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Get the first element and deque without it if it's not empty.

valueunsnoc :: Deque a -> Maybe (a, Deque a)
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Get the last element and deque without it if it's not empty.

valuenull :: Deque a -> Bool
#

\mathcal{O}(1). Check whether deque is empty.

valuehead :: Deque a -> Maybe a
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Get the first element if deque is not empty.

valuelast :: Deque a -> Maybe a
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Get the last element if deque is not empty.

valuetail :: Deque a -> Deque a
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Keep all elements but the first one.

In case of empty deque returns an empty deque.

valueinit :: Deque a -> Deque a
#

\mathcal{O}(1), occasionally \mathcal{O}(n). Keep all elements but the last one.

In case of empty deque returns an empty deque.