Module

Data.NonEmpty

This module defines a generic non-empty data structure, which adds an additional element to any container type.

#NonEmpty

data NonEmpty f a

A non-empty container of elements of type a.

For example:

nonEmptyList :: NonEmpty List Int
nonEmptyList = 0 :| empty

Constructors

Instances

#singleton

singleton :: forall f a. Plus f => a -> NonEmpty f a

Create a non-empty structure with a single value.

#(:|)

Operator alias for Data.NonEmpty.NonEmpty (right-associative / precedence 5)

An infix synonym for NonEmpty.

#foldl1

foldl1 :: forall f a. Foldable f => (a -> a -> a) -> NonEmpty f a -> a

Fold a non-empty structure, collecting results using a binary operation.

#fromNonEmpty

fromNonEmpty :: forall f a r. (a -> f a -> r) -> NonEmpty f a -> r

#oneOf

oneOf :: forall f a. Alternative f => NonEmpty f a -> f a

#head

head :: forall f a. NonEmpty f a -> a

Get the 'first' element of a non-empty container.

#tail

tail :: forall f a. NonEmpty f a -> f a

Get everything but the 'first' element of a non-empty container.

Modules