module Bricks.Internal.Seq
( Seq
, (<|), (|>)
, adjust
, adjustLast
, append
, concat
, concatMap
, dropWhileL
, dropWhileR
, empty
, filter
, fromList
, intersperse
, length
, map
, minimum
, maximum
, null
, toList
, trimWhile
, singleton
) where
import Data.Sequence (Seq, adjust, dropWhileL, dropWhileR, empty, filter,
fromList, length, null, singleton, (<|), (><), (|>))
import Data.Bool (Bool (..))
import Data.Foldable (Foldable)
import qualified Data.Foldable as Foldable
import Data.Functor (fmap)
import qualified Data.List as List
import Data.Maybe (Maybe (..))
import Data.Ord (Ord)
import Prelude (Num (..))
append :: Seq a -> Seq a -> Seq a
append = (><)
intersperse :: a -> Seq a -> Seq a
intersperse x xs =
fromList (List.intersperse x (Foldable.toList xs))
concat :: Foldable f => f (Seq a) -> Seq a
concat = Foldable.fold
concatMap :: Foldable f => (a -> Seq b) -> f a -> Seq b
concatMap f xs = concat (fmap f (Foldable.toList xs))
minimum :: Ord a => Seq a -> Maybe a
minimum xs =
if null xs then Nothing else Just (List.minimum (Foldable.toList xs))
maximum :: Ord a => Seq a -> Maybe a
maximum xs =
if null xs then Nothing else Just (List.maximum (Foldable.toList xs))
map :: (a -> b) -> Seq a -> Seq b
map = fmap
toList :: Seq a -> [a]
toList = Foldable.toList
adjustLast :: (a -> a) -> Seq a -> Seq a
adjustLast f xs = adjust f (length xs 1) xs
trimWhile :: (a -> Bool) -> Seq a -> Seq a
trimWhile f xs = dropWhileL f (dropWhileR f xs)