{-# OPTIONS_GHC -Wno-orphans #-}

module Data.Sequence.NonEmpty.Extra () where

import           Data.Foldable
import           Data.Sequence.NonEmpty
import           NoThunks.Class

-- | Instance for @'NESeq'@ which only checks for thunks on the elements
--
-- The internal fingertree in @'NESeq'@ might have thunks, which is essential for
-- its asymptotic complexity.
--
-- Note: see documentation of @'NoThunks' ('Seq' a)@
instance NoThunks a => NoThunks (NESeq a) where
  showTypeOf :: Proxy (NESeq a) -> String
showTypeOf Proxy (NESeq a)
_ = String
"NESeq"
  wNoThunks :: Context -> NESeq a -> IO (Maybe ThunkInfo)
wNoThunks Context
ctxt = Context -> [a] -> IO (Maybe ThunkInfo)
forall a. NoThunks a => Context -> [a] -> IO (Maybe ThunkInfo)
noThunksInValues Context
ctxt ([a] -> IO (Maybe ThunkInfo))
-> (NESeq a -> [a]) -> NESeq a -> IO (Maybe ThunkInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NESeq a -> [a]
forall a. NESeq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList