Module Data.NonEmpty

A non-empty list

Imports

Table of Content

Definitions

data NonEmpty a

A NonEmpty is like a list, but never empty.

Constructors

NonEmpty {neHead ∷ a, neTail ∷ [a]}

Member Functions

neHeadNonEmpty α → α

access field neHead

neTailNonEmpty α → [α]

The head of the non-empty list. The tail of the non-empty list.

nonEmpty ∷ a → [a] → NonEmpty a

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

|: ∷ a → [a] → NonEmpty a
infixr  6

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

toNonEmpty[a]Maybe (NonEmpty a)

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

toNonEmpty'NonEmpty a → [a]NonEmpty a

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

unsafeToNonEmpty[a]NonEmpty a

WARNING: Fails if given the empty list.

Tries to convert a list to a NonEmpty.

.: ∷ a → NonEmpty aNonEmpty a
infixr  6

Prepends a value to a NonEmpty.

reverseNonEmpty a → NonEmpty a

Reverses the elements of the (finite) NonEmpty.

scanl ∷ (b → a → b) → bNonEmpty a → NonEmpty b

scanl is similar to foldl, but returns a NonEmpty of successive reduced values from the left

scanl1 ∷ (a → a → a) → NonEmpty a → NonEmpty a

scanl1 is similar to foldl1, but returns a NonEmpty of successive reduced values from the left

scanr ∷ (a → b → b) → b → NonEmpty a → NonEmpty b

scanr is similar to foldr, but returns a NonEmpty of successive reduced values from the right

scanr1 ∷ (a → a → a) → NonEmpty a → NonEmpty a

scanr1 is similar to foldr1, but returns a NonEmpty of successive reduced values from the right

iterate ∷ (a → a) → a → NonEmpty a

iterate f x returns an infinite NonEmpty of repeated applications of f to x

cycleListSource src ⇒ src a → NonEmpty a

cycle ties a finite NonEmpty into a circular one, or equivalently, the infinite repetition of the original NonEmpty. It is the identity on infinite NonEmptys.

initsNonEmpty a → [NonEmpty a]

The inits function returns all initial segments of the argument, shortest first.

tailsNonEmpty a → [NonEmpty a]

The tails function returns all final segments of the argument, longest first.

sortOrd a ⇒ NonEmpty a → NonEmpty a

The sort function implements a stable sorting algorithm.

insertOrd a ⇒ a → NonEmpty a → NonEmpty a

The insert function takes an element and a NonEmpty and inserts the element into the NonEmpty at the last position where it is still less than or equal to the next element.

unzipNonEmpty (a, b) → (NonEmpty a, NonEmpty b)

unzip transforms a NonEmpty of pairs into a NonEmpty of first components and a NonEmpty of second components.

zipNonEmpty aNonEmpty bNonEmpty (a, b)

zip takes two NonEmptys and returns a NonEmpty of corresponding pairs. If one input NonEmptys is short, excess elements of the longer NonEmpty are discarded.

Instances

instance Eq a ⇒ Eq (NonEmpty a)

Member Functions

!=Eq α ⇒ NonEmpty αNonEmpty αBool
infix  7

inherited from Eq.!=

==Eq α ⇒ NonEmpty αNonEmpty αBool
infix  7

Function generated for derived instance.

hashCodeEq α ⇒ NonEmpty αInt

Function generated for derived instance.

instance Foldable NonEmpty

Member Functions

foldMonoid α ⇒ NonEmpty α → α

inherited from Foldable.fold

fold1Semigroup α ⇒ NonEmpty α → α

inherited from Foldable.fold1

foldMapMonoid β ⇒ (α → β) → NonEmpty α → β

inherited from Foldable.foldMap

foldMap1Semigroup β ⇒ (α → β) → NonEmpty α → β

inherited from Foldable.foldMap1

foldl ∷ (α → β → α) → αNonEmpty β → α
foldl1 ∷ (α → α → α) → NonEmpty α → α

inherited from Foldable.foldl1

foldr ∷ (α → β → β) → β → NonEmpty α → β
foldr1 ∷ (α → α → α) → NonEmpty α → α

inherited from Foldable.foldr1

instance Functor NonEmpty

Member Functions

fmap ∷ (α → β) → NonEmpty αNonEmpty β
infixl  4
instance ListMonoid NonEmpty

Member Functions

++NonEmpty αNonEmpty αNonEmpty α
infixr  13
concat[NonEmpty α]NonEmpty α

inherited from ListMonoid.concat

emptyNonEmpty α
nullNonEmpty α → Bool
instance ListSource NonEmpty

Member Functions

toListNonEmpty α → [α]
instance Monad NonEmpty

Member Functions

*>NonEmpty α → NonEmpty β → NonEmpty β
infixl  4

inherited from Applicative.*>

<*NonEmpty α → NonEmpty β → NonEmpty α
infixl  4

inherited from Applicative.<*

<*>NonEmpty (α→β) → NonEmpty α → NonEmpty β
infixl  4

inherited from Monad.<*>

>>NonEmpty αNonEmpty β → NonEmpty β
infixl  3

inherited from Monad.>>

>>=NonEmpty α → (α → NonEmpty β) → NonEmpty β
infixl  3
joinNonEmpty (NonEmpty α)NonEmpty α

inherited from Monad.join

pure ∷ α → NonEmpty α
instance Ord a ⇒ Ord (NonEmpty a)

Member Functions

<Ord α ⇒ NonEmpty αNonEmpty αBool
infix  9

inherited from Ord.<

<=Ord α ⇒ NonEmpty αNonEmpty αBool
infix  9

inherited from Ord.<=

<=>Ord α ⇒ NonEmpty αNonEmpty αOrdering
infix  8

Function generated for derived instance.

>Ord α ⇒ NonEmpty αNonEmpty αBool
infix  9

inherited from Ord.>

>=Ord α ⇒ NonEmpty αNonEmpty αBool
infix  9

inherited from Ord.>=

compareOrd α ⇒ NonEmpty αNonEmpty αOrdering
infix  8

inherited from Ord.compare

maxOrd α ⇒ NonEmpty αNonEmpty αNonEmpty α

inherited from Ord.max

minOrd α ⇒ NonEmpty αNonEmpty αNonEmpty α

inherited from Ord.min

instance Semigroup (NonEmpty a)

Member Functions

mappendNonEmpty αNonEmpty αNonEmpty α
infixr  13
sconcat[NonEmpty α]NonEmpty α

inherited from Semigroup.sconcat

stimesIntNonEmpty α → NonEmpty α

inherited from Semigroup.stimes

instance Show a ⇒ Show (NonEmpty a)

Member Functions

displayShow α ⇒ NonEmpty αString

inherited from Show.display

showShow α ⇒ NonEmpty αString
showCharsShow α ⇒ NonEmpty α → [Char]

inherited from Show.showChars

showListShow α ⇒ [NonEmpty α]StringString

inherited from Show.showList

showsPrecShow α ⇒ IntNonEmpty αStringString

inherited from Show.showsPrec

showsubShow α ⇒ NonEmpty αString

inherited from Show.showsub

instance Traversable NonEmpty

Member Functions

mapMMonad γ ⇒ (α → γ β) → NonEmpty α → γ (NonEmpty β)

inherited from Traversable.mapM

sequenceMonad β ⇒ NonEmpty (β α) → β (NonEmpty α)

inherited from Traversable.sequence

sequenceAApplicative β ⇒ NonEmpty (β α) → β (NonEmpty α)

inherited from Traversable.sequenceA

traverseApplicative γ ⇒ (α → γ β) → NonEmpty α → γ (NonEmpty β)

Functions and Values by Type

(a → a → a) → NonEmpty a → NonEmpty a

scanl1, scanr1

(a → a) → a → NonEmpty a

iterate

(α → α → α) → NonEmpty α → α

Foldable_NonEmpty.foldr1, Foldable_NonEmpty.foldl1

NonEmpty (NonEmpty α) → NonEmpty α

Monad_NonEmpty.join

NonEmpty a → [a] → NonEmpty a

toNonEmpty'

NonEmpty a → NonEmpty a

reverse

NonEmpty a → [NonEmpty a]

inits, tails

NonEmpty α → ([α]→[α]) → NonEmpty α

NonEmpty.chg$neTail

NonEmpty α → (α→α) → NonEmpty α

NonEmpty.chg$neHead

NonEmpty α → NonEmpty α → NonEmpty α

ListMonoid_NonEmpty.++, Semigroup_NonEmpty.mappend

NonEmpty α → [α] → NonEmpty α

NonEmpty.upd$neTail

NonEmpty α → α → NonEmpty α

NonEmpty.upd$neHead

NonEmpty α → [α]

ListSource_NonEmpty.toList, NonEmpty.neTail

NonEmpty α → Bool

ListMonoid_NonEmpty.null

NonEmpty α → α

NonEmpty.neHead

[NonEmpty α] → NonEmpty α

ListMonoid_NonEmpty.concat, Semigroup_NonEmpty.sconcat

[a] → NonEmpty a

unsafeToNonEmpty

[a] → Maybe (NonEmpty a)

toNonEmpty

IntNonEmpty α → NonEmpty α

Semigroup_NonEmpty.stimes

a → NonEmpty a → NonEmpty a

.:

a → [a] → NonEmpty a

nonEmpty, |:, NonEmpty.NonEmpty

α → NonEmpty α

Monad_NonEmpty.pure

α → Bool

NonEmpty.has$neHead, NonEmpty.has$neTail

Monoid α ⇒ NonEmpty α → α

Foldable_NonEmpty.fold

Semigroup α ⇒ NonEmpty α → α

Foldable_NonEmpty.fold1

Eq α ⇒ NonEmpty α → NonEmpty α → Bool

Eq_NonEmpty.!=, Eq_NonEmpty.==

Eq α ⇒ NonEmpty α → Int

Eq_NonEmpty.hashCode

Ord a ⇒ NonEmpty a → NonEmpty a

sort

Ord a ⇒ a → NonEmpty a → NonEmpty a

insert

Ord α ⇒ NonEmpty α → NonEmpty α → NonEmpty α

Ord_NonEmpty.min, Ord_NonEmpty.max

Ord α ⇒ NonEmpty α → NonEmpty α → Bool

Ord_NonEmpty.>=, Ord_NonEmpty.<, Ord_NonEmpty.<=, Ord_NonEmpty.>

Ord α ⇒ NonEmpty α → NonEmpty α → Ordering

Ord_NonEmpty.compare, Ord_NonEmpty.<=>

Show α ⇒ NonEmpty α → String

Show_NonEmpty.showsub, Show_NonEmpty.display, Show_NonEmpty.show

Show α ⇒ NonEmpty α → [Char]

Show_NonEmpty.showChars

Show α ⇒ [NonEmpty α] → StringString

Show_NonEmpty.showList

Show α ⇒ IntNonEmpty α → StringString

Show_NonEmpty.showsPrec

NonEmpty α

ListMonoid_NonEmpty.empty

(a → b → b) → b → NonEmpty a → NonEmpty b

scanr

(b → a → b) → b → NonEmpty a → NonEmpty b

scanl

(α → β → α) → α → NonEmpty β → α

Foldable_NonEmpty.foldl

(α → β → β) → β → NonEmpty α → β

Foldable_NonEmpty.foldr

(α → β) → NonEmpty α → NonEmpty β

Functor_NonEmpty.fmap

NonEmpty (a, b) → (NonEmpty a, NonEmpty b)

unzip

NonEmpty (α→β) → NonEmpty α → NonEmpty β

Monad_NonEmpty.<*>

NonEmpty a → NonEmpty b → NonEmpty (a, b)

zip

NonEmpty α → (α → NonEmpty β) → NonEmpty β

Monad_NonEmpty.>>=

NonEmpty α → NonEmpty β → NonEmpty α

Monad_NonEmpty.<*

NonEmpty α → NonEmpty β → NonEmpty β

Monad_NonEmpty.>>, Monad_NonEmpty.*>

Monoid β ⇒ (α → β) → NonEmpty α → β

Foldable_NonEmpty.foldMap

Semigroup β ⇒ (α → β) → NonEmpty α → β

Foldable_NonEmpty.foldMap1

ListSource src ⇒ src a → NonEmpty a

cycle

Applicative β ⇒ NonEmpty (β α) → β (NonEmpty α)

Traversable_NonEmpty.sequenceA

Monad β ⇒ NonEmpty (β α) → β (NonEmpty α)

Traversable_NonEmpty.sequence

Applicative γ ⇒ (α → γ β) → NonEmpty α → γ (NonEmpty β)

Traversable_NonEmpty.traverse

Monad γ ⇒ (α → γ β) → NonEmpty α → γ (NonEmpty β)

Traversable_NonEmpty.mapM

Valid HTML 4.01 Strict