HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduledeque-0.4.4.4Haskell2010

Deque.Strict

Definitions of strict Deque.

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

Synopsis
  • Packagedeque-0.4.4.4
  • Exports22
  • LanguageHaskell2010
  • LicenceMIT
  • SourceStrict.hs
datadata Deque a

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

Instances21Monad, Functor, MonadFail, Applicative, Foldable, Traversable, …
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]
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.