{-|
Definitions of lazy Deque.

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

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

{-| Convert strict deque to lazy deque. -}
fromStrict :: StrictDefs.Deque a -> LazyDefs.Deque a
fromStrict :: Deque a -> Deque a
fromStrict (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)

{-| Convert lazy deque to strict deque. -}
toStrict :: LazyDefs.Deque a -> StrictDefs.Deque a
toStrict :: Deque a -> Deque a
toStrict (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)