NonEmptyList-0.0.8: A list with a length of at least one.

Data.List.NonEmpty

Contents

Description

A type-safe list that has at least one element.

Synopsis

# Documentation

data NonEmpty a Source

An list with at least one element.

Instances

 Monad NonEmpty Functor NonEmpty Typeable1 NonEmpty Applicative NonEmpty Foldable NonEmpty Traversable NonEmpty Eq a => Eq (NonEmpty a) Data a => Data (NonEmpty a) Ord a => Ord (NonEmpty a) Show a => Show (NonEmpty a) Arbitrary a => Arbitrary (NonEmpty a) Semigroup (NonEmpty a)

# Accessors

neHead :: NonEmpty a -> aSource

The head of the non-empty list.

neTail :: NonEmpty a -> [a]Source

The tail of the non-empty list.

# Constructors

Arguments

 :: a The head. -> [a] The tail. -> NonEmpty a

Constructs a non-empty list with the given head and tail.

Arguments

 :: a The head. -> [a] The tail. -> NonEmpty a

Constructs a non-empty list with the given head and tail (an alias for `nonEmpty`).

Arguments

 :: [a] The list to convert. -> Maybe (NonEmpty a)

Tries to convert a list to a `NonEmpty` returning `Nothing` if the given list is empty.

Arguments

 :: [a] The list to convert (must not be empty). -> NonEmpty a

WARNING: Fails if given the empty list. Tries to convert a list to a `NonEmpty`.

Arguments

 :: a The value to prepend. -> NonEmpty a The non-empty list to prepend to. -> NonEmpty a

Prepends a value to a non-empty list.

# List functions

suml :: Semigroup a => NonEmpty a -> aSource

Reduce left on the given non-empty list using a semigroup.

sumr :: Semigroup a => NonEmpty a -> aSource

Reduce right on the given non-empty list using a semigroup.

Reverses the elements of the (finite) non-empty list.

scanl :: (b -> a -> b) -> b -> NonEmpty a -> NonEmpty bSource

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

scanr :: (a -> b -> b) -> b -> NonEmpty a -> NonEmpty bSource

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

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

cycle :: Foldable f => f a -> NonEmpty aSource

inits :: [a] -> NonEmpty [a]Source

tails :: [a] -> NonEmpty [a]Source

insert :: Ord a => a -> NonEmpty a -> NonEmpty aSource