NonEmptyList-0.0.9: 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

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

nonEmptySource

Arguments

:: a

The head.

-> [a]

The tail.

-> NonEmpty a 

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

(|:)Source

Arguments

:: a

The head.

-> [a]

The tail.

-> NonEmpty a 

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

toNonEmptySource

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.

toNonEmpty'Source

Arguments

:: NonEmpty a

The default return value if the given list is empty.

-> [a]

The list to convert.

-> NonEmpty a 

Converts a list to a NonEmpty using the given default value for the empty list case.

unsafeToNonEmptySource

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.

(.:)Source

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

reverseSource

Arguments

:: NonEmpty a

A finite non-empty list.

-> NonEmpty a 

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