HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduledeque-0.4.4.4Haskell2010

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.4
  • 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
#

O(1). Add element in the beginning.

valueshiftLeft :: 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]
valueshiftRight :: 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]
valuefilter :: (a -> Bool) -> Deque a -> Deque a
#

O(n). Leave only the elements satisfying the predicate.

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

O(n). Leave only the specified amount of first elements.

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

O(n). Drop the specified amount of first elements.

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

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

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

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

valuehead :: Deque a -> Maybe a
#

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

valuelast :: Deque a -> Maybe a
#

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

valuetail :: Deque a -> Deque a
#

O(1), occasionally O(n). Keep all elements but the first one.

In case of empty deque returns an empty deque.

valueinit :: 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.