base-compat-batteries-0.11.1: base-compat with extra batteries

Safe Haskell | Safe
Language | Haskell98

Data.List.NonEmpty.Compat

Contents

- The type of non-empty streams
- Non-empty stream transformations
- Basic functions
- Building streams
- Extracting sublists
- Sublist predicates
- "Set" operations
- Indexing streams
- Zipping and unzipping streams
- Converting to and from a list

Description

This backports the modern Data.Semigroup interface back to `base-4.9`/GHC 8.0.

Synopsis

- data NonEmpty a = a :| [a]
- map :: (a -> b) -> NonEmpty a -> NonEmpty b
- intersperse :: a -> NonEmpty a -> NonEmpty a
- scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b
- scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b
- scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
- scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
- transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a)
- sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a
- sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a
- length :: NonEmpty a -> Int
- head :: NonEmpty a -> a
- tail :: NonEmpty a -> [a]
- last :: NonEmpty a -> a
- init :: NonEmpty a -> [a]
- (<|) :: a -> NonEmpty a -> NonEmpty a
- cons :: a -> NonEmpty a -> NonEmpty a
- uncons :: NonEmpty a -> (a, Maybe (NonEmpty a))
- unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b
- sort :: Ord a => NonEmpty a -> NonEmpty a
- reverse :: NonEmpty a -> NonEmpty a
- inits :: Foldable f => f a -> NonEmpty [a]
- tails :: Foldable f => f a -> NonEmpty [a]
- iterate :: (a -> a) -> a -> NonEmpty a
- repeat :: a -> NonEmpty a
- cycle :: NonEmpty a -> NonEmpty a
- unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b
- insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a
- some1 :: Alternative f => f a -> f (NonEmpty a)
- take :: Int -> NonEmpty a -> [a]
- drop :: Int -> NonEmpty a -> [a]
- splitAt :: Int -> NonEmpty a -> ([a], [a])
- takeWhile :: (a -> Bool) -> NonEmpty a -> [a]
- dropWhile :: (a -> Bool) -> NonEmpty a -> [a]
- span :: (a -> Bool) -> NonEmpty a -> ([a], [a])
- break :: (a -> Bool) -> NonEmpty a -> ([a], [a])
- filter :: (a -> Bool) -> NonEmpty a -> [a]
- partition :: (a -> Bool) -> NonEmpty a -> ([a], [a])
- group :: (Foldable f, Eq a) => f a -> [NonEmpty a]
- groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a]
- groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a]
- groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a]
- group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a)
- groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a)
- groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
- groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
- isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool
- nub :: Eq a => NonEmpty a -> NonEmpty a
- nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a
- (!!) :: NonEmpty a -> Int -> a
- zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)
- zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c
- unzip :: Functor f => f (a, b) -> (f a, f b)
- fromList :: [a] -> NonEmpty a
- toList :: NonEmpty a -> [a]
- nonEmpty :: [a] -> Maybe (NonEmpty a)
- xor :: NonEmpty Bool -> Bool

# The type of non-empty streams

data NonEmpty a #

Constructors

a :| [a] |

#### Instances

Instances details

Monad NonEmpty |
Instance details Defined in GHC.Base Methods (>>=) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b # (>>) :: NonEmpty a -> NonEmpty b -> NonEmpty b # return :: a -> NonEmpty a #
Functor NonEmpty |
Instance details Defined in GHC.Base Methods fmap :: (a -> b) -> NonEmpty a -> NonEmpty b # (<$) :: a -> NonEmpty b -> NonEmpty a #
Applicative NonEmpty |
Instance details Defined in GHC.Base Methods pure :: a -> NonEmpty a (<*>) :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b liftA2 :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c (*>) :: NonEmpty a -> NonEmpty b -> NonEmpty b (<*) :: NonEmpty a -> NonEmpty b -> NonEmpty a
Foldable NonEmpty |

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => NonEmpty m -> m

foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m

foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m

foldr :: (a -> b -> b) -> b -> NonEmpty a -> b

foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b

foldl :: (b -> a -> b) -> b -> NonEmpty a -> b

foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b

foldr1 :: (a -> a -> a) -> NonEmpty a -> a

foldl1 :: (a -> a -> a) -> NonEmpty a -> a

toList :: NonEmpty a -> [a]

null :: NonEmpty a -> Bool

length :: NonEmpty a -> Int

elem :: Eq a => a -> NonEmpty a -> Bool

maximum :: Ord a => NonEmpty a -> a

minimum :: Ord a => NonEmpty a -> a

sum :: Num a => NonEmpty a -> a

product :: Num a => NonEmpty a -> a

Traversable NonEmpty |
Instance details Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> NonEmpty a -> f (NonEmpty b) sequenceA :: Applicative f => NonEmpty (f a) -> f (NonEmpty a) mapM :: Monad m => (a -> m b) -> NonEmpty a -> m (NonEmpty b) # sequence :: Monad m => NonEmpty (m a) -> m (NonEmpty a) #
Eq a => Eq (NonEmpty a) |
Instance details Defined in GHC.Base Methods (==) :: NonEmpty a -> NonEmpty a -> Bool (/=) :: NonEmpty a -> NonEmpty a -> Bool
Ord a => Ord (NonEmpty a) |
Instance details Defined in GHC.Base Methods compare :: NonEmpty a -> NonEmpty a -> Ordering (<) :: NonEmpty a -> NonEmpty a -> Bool (<=) :: NonEmpty a -> NonEmpty a -> Bool (>) :: NonEmpty a -> NonEmpty a -> Bool (>=) :: NonEmpty a -> NonEmpty a -> Bool max :: NonEmpty a -> NonEmpty a -> NonEmpty a min :: NonEmpty a -> NonEmpty a -> NonEmpty a
Read a => Read (NonEmpty a) |
Instance details Defined in GHC.Read Methods readsPrec :: Int -> ReadS (NonEmpty a) # readList :: ReadS [NonEmpty a] # readPrec :: ReadPrec (NonEmpty a) # readListPrec :: ReadPrec [NonEmpty a] #
Show a => Show (NonEmpty a) |
Instance details Defined in GHC.Show Methods showsPrec :: Int -> NonEmpty a -> ShowS show :: NonEmpty a -> String showList :: [NonEmpty a] -> ShowS
Semigroup (NonEmpty a) |
Instance details Defined in GHC.Base Methods (<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a # sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a # stimes :: Integral b => b -> NonEmpty a -> NonEmpty a #

# Non-empty stream transformations

map :: (a -> b) -> NonEmpty a -> NonEmpty b #

intersperse :: a -> NonEmpty a -> NonEmpty a #

scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b #

scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b #

scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a #

scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a #

transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a) #

sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a #

sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a #

# Basic functions

length :: NonEmpty a -> Int #

head :: NonEmpty a -> a #

tail :: NonEmpty a -> [a] #

last :: NonEmpty a -> a #

init :: NonEmpty a -> [a] #

(<|) :: a -> NonEmpty a -> NonEmpty a #

cons :: a -> NonEmpty a -> NonEmpty a #

uncons :: NonEmpty a -> (a, Maybe (NonEmpty a)) #

unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b #

sort :: Ord a => NonEmpty a -> NonEmpty a #

reverse :: NonEmpty a -> NonEmpty a #

inits :: Foldable f => f a -> NonEmpty [a] #

tails :: Foldable f => f a -> NonEmpty [a] #

# Building streams

iterate :: (a -> a) -> a -> NonEmpty a #

repeat :: a -> NonEmpty a #

cycle :: NonEmpty a -> NonEmpty a #

unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b #

insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a #

some1 :: Alternative f => f a -> f (NonEmpty a) #

# Extracting sublists

take :: Int -> NonEmpty a -> [a] #

drop :: Int -> NonEmpty a -> [a] #

splitAt :: Int -> NonEmpty a -> ([a], [a]) #

takeWhile :: (a -> Bool) -> NonEmpty a -> [a] #

dropWhile :: (a -> Bool) -> NonEmpty a -> [a] #

span :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #

break :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #

filter :: (a -> Bool) -> NonEmpty a -> [a] #

partition :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #

group :: (Foldable f, Eq a) => f a -> [NonEmpty a] #

groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] #

groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a] #

groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a] #

group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) #

groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) #

groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) #

groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) #

# Sublist predicates

isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool #

# "Set" operations

nub :: Eq a => NonEmpty a -> NonEmpty a #

nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a #

# Indexing streams

(!!) :: NonEmpty a -> Int -> a #

# Zipping and unzipping streams

zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) #

zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #

unzip :: Functor f => f (a, b) -> (f a, f b) #

# Converting to and from a list

fromList :: [a] -> NonEmpty a #

toList :: NonEmpty a -> [a] #

nonEmpty :: [a] -> Maybe (NonEmpty a) #

xor :: NonEmpty Bool -> Bool #