rio-0.1.22.0: A standard library for Haskell

Safe Haskell | Safe-Inferred
Language | Haskell2010

RIO.NonEmpty

Contents

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

Description

`NonEmpty` list. Import as:

    import qualified RIO.NonEmpty as NE

This module does not export any partial functions. For those, see RIO.NonEmpty.Partial

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
- 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
- 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)
- nonEmpty :: [a] -> Maybe (NonEmpty a)
- toList :: NonEmpty a -> [a]
- xor :: NonEmpty Bool -> Bool

# The type of non-empty streams

data NonEmpty a #

Constructors

a :| [a] |

#### Instances

Instances details

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) #
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 #
Functor NonEmpty |
Instance details Defined in GHC.Base Methods fmap :: (a -> b) -> NonEmpty a -> NonEmpty b # (<$) :: a -> NonEmpty b -> NonEmpty a #
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 #
NFData1 NonEmpty |
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> NonEmpty a -> ()
Hashable1 NonEmpty | Since: hashable-1.3.1.0
Instance details Defined in Data.Hashable.Class Methods liftHashWithSalt :: (Int -> a -> Int) -> Int -> NonEmpty a -> Int #
Generic1 NonEmpty |
Instance details Defined in GHC.Generics Associated Types type Rep1 NonEmpty :: k -> Type Methods from1 :: forall (a :: k). NonEmpty a -> Rep1 NonEmpty a to1 :: forall (a :: k). Rep1 NonEmpty a -> NonEmpty a
Lift a => Lift (NonEmpty a :: Type) |
Instance details Defined in Language.Haskell.TH.Syntax Methods lift :: Quote m => NonEmpty a -> m Exp liftTyped :: forall (m :: Type -> Type). Quote m => NonEmpty a -> Code m (NonEmpty a)
Data a => Data (NonEmpty a) |
Instance details Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NonEmpty a -> c (NonEmpty a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NonEmpty a) # toConstr :: NonEmpty a -> Constr # dataTypeOf :: NonEmpty a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NonEmpty a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NonEmpty a)) # gmapT :: (forall b. Data b => b -> b) -> NonEmpty a -> NonEmpty a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NonEmpty a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NonEmpty a -> r # gmapQ :: (forall d. Data d => d -> u) -> NonEmpty a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NonEmpty a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) #
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
Generic (NonEmpty a) |
Instance details Defined in GHC.Generics Associated Types type Rep (NonEmpty a) :: Type -> Type Methods from :: NonEmpty a -> Rep (NonEmpty a) x to :: Rep (NonEmpty a) x -> NonEmpty a
IsList (NonEmpty a) |
Instance details Defined in GHC.IsList Associated Types type Item (NonEmpty a) Methods fromList :: [Item (NonEmpty a)] -> NonEmpty a fromListN :: Int -> [Item (NonEmpty a)] -> NonEmpty a toList :: NonEmpty a -> [Item (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
NFData a => NFData (NonEmpty a) |
Instance details Defined in Control.DeepSeq Methods rnf :: 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 #
Hashable a => Hashable (NonEmpty a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> NonEmpty a -> Int # hash :: NonEmpty a -> Int #
Ixed (NonEmpty a) |
Instance details Defined in Lens.Micro.Internal Methods ix :: Index (NonEmpty a) -> Traversal' (NonEmpty a) (IxValue (NonEmpty a)) #
Each (NonEmpty a) (NonEmpty b) a b |
Instance details Defined in Lens.Micro.Internal Methods each :: Traversal (NonEmpty a) (NonEmpty b) a b #
type Rep1 NonEmpty |
Instance details Defined in GHC.Generics type Rep1 NonEmpty = D1 ('MetaData "NonEmpty" "GHC.Base" "base" 'False) (C1 ('MetaCons ":|" ('InfixI 'RightAssociative 5) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 List)))
type Rep (NonEmpty a) |
Instance details Defined in GHC.Generics type Rep (NonEmpty a) = D1 ('MetaData "NonEmpty" "GHC.Base" "base" 'False) (C1 ('MetaCons ":|" ('InfixI 'RightAssociative 5) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))
type Item (NonEmpty a) |
Instance details Defined in GHC.IsList type Item (NonEmpty a) = a
type Index (NonEmpty a) |
Instance details Defined in Lens.Micro.Internal type Index (NonEmpty a) = Int
type IxValue (NonEmpty a) |
Instance details Defined in Lens.Micro.Internal type IxValue (NonEmpty a) = 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 #

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-like operations

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

nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty 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

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

toList :: NonEmpty a -> [a] #

xor :: NonEmpty Bool -> Bool #