{-|
Definitions of strict Deque.

The typical `toList` and `fromList` conversions are provided by means of
the `Foldable` and `IsList` instances.
-}
module Deque.Strict
(
  StrictDefs.Deque,
  fromLazy,
  toLazy,
  StrictDefs.fromConsAndSnocLists,
  StrictDefs.cons,
  StrictDefs.snoc,
  StrictDefs.reverse,
  StrictDefs.shiftLeft,
  StrictDefs.shiftRight,
  StrictDefs.filter,
  StrictDefs.take,
  StrictDefs.drop,
  StrictDefs.takeWhile,
  StrictDefs.dropWhile,
  StrictDefs.span,
  StrictDefs.uncons,
  StrictDefs.unsnoc,
  StrictDefs.null,
  StrictDefs.head,
  StrictDefs.last,
  StrictDefs.tail,
  StrictDefs.init,
)
where

import Deque.Prelude
import qualified Deque.Lazy.Defs as LazyDefs
import qualified Deque.Strict.Defs as StrictDefs

{-| Convert lazy deque to strict deque. -}
fromLazy :: LazyDefs.Deque a -> StrictDefs.Deque a
fromLazy :: Deque a -> Deque a
fromLazy (LazyDefs.Deque [a]
consList [a]
snocList) = List a -> List a -> Deque a
forall a. List a -> List a -> Deque a
StrictDefs.Deque ([Item (List a)] -> List a
forall l. IsList l => [Item l] -> l
fromList [a]
[Item (List a)]
consList) ([Item (List a)] -> List a
forall l. IsList l => [Item l] -> l
fromList [a]
[Item (List a)]
snocList)

{-| Convert strict deque to lazy deque. -}
toLazy :: StrictDefs.Deque a -> LazyDefs.Deque a
toLazy :: Deque a -> Deque a
toLazy (StrictDefs.Deque List a
consList List a
snocList) = [a] -> [a] -> Deque a
forall a. [a] -> [a] -> Deque a
LazyDefs.Deque (List a -> [Item (List a)]
forall l. IsList l => l -> [Item l]
toList List a
consList) (List a -> [Item (List a)]
forall l. IsList l => l -> [Item l]
toList List a
snocList)