A double-ended queue supporting any underlying vector type and any monad.
This implements a circular double-ended queue with exponential growth.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulerio-0.1.22.0Haskell2010
A double-ended queue supporting any underlying vector type and any monad.
This implements a circular double-ended queue with exponential growth.
A Deque specialized to unboxed vectors.
A Deque specialized to storable vectors.
A Deque specialized to boxed vectors.
Create a new, empty Deque
O(1) - Get the number of elements that is currently in the Deque
Pop the first value from the beginning of the Deque
Pop the first value from the end of the Deque
Push a new value to the beginning of the Deque
Push a new value to the end of the Deque
Convert to an immutable vector of any type. If resulting pure vector corresponds to the mutable one used by the Deque, it will be more efficient to use freezeDeque instead.
:set -XTypeApplicationsimport qualified RIO.Vector.Unboxed as Uimport qualified RIO.Vector.Storable as Sd <- newDeque @U.MVector @IntmapM_ (pushFrontDeque d) [0..10]dequeToVector @S.Vector d[10,9,8,7,6,5,4,3,2,1,0]
Yield an immutable copy of the underlying mutable vector. The difference from dequeToVector
is that the the copy will be performed with a more efficient memcpy, rather than element by
element. The downside is that the resulting vector type must be the one that corresponds to the
mutable one that is used in the Deque.
:set -XTypeApplicationsimport qualified RIO.Vector.Unboxed as Ud <- newDeque @U.MVector @IntmapM_ (pushFrontDeque d) [0..10]freezeDeque @U.Vector d[10,9,8,7,6,5,4,3,2,1,0]
Helper function to assist with type inference, forcing usage of an unboxed vector.
Helper function to assist with type inference, forcing usage of a storable vector.
Helper function to assist with type inference, forcing usage of a boxed vector.