-- | Strict binary random-access lists.
--
-- This module is intended to be imported qualified.
--

{-# LANGUAGE CPP, BangPatterns, PatternSynonyms, PatternGuards #-}
module Data.Nested.Seq.Binary.Strict 

#include "exp_imp.inc"

--------------------------------------------------------------------------------

data StrictPair a = StrictPair !a !a deriving (Eq,Show)

type Pair a = StrictPair a

-- | The strict sequence type. See "Data.Nested.Seq.Lazy" for more detailed information.
data Seq a 
  = Nil                      -- ^ empty sequence
  | ZZ    !(Seq (Pair a))    -- ^ even sequence (we will use a pattern synonym to maintain an invariant, hence the strange name)
  | O  !a !(Seq (Pair a))    -- ^ odd sequence
#ifdef TESTING
  deriving Show
#endif

-- so that we can use the same source code for the strict and the lazy versions
pattern Pair :: a -> a -> Pair a
pattern Pair x y = StrictPair x y

--------------------------------------------------------------------------------

#include "sequence.inc"

--------------------------------------------------------------------------------