Module

Data.NonEmpty

Package
purescript-nonempty
Repository
purescript/purescript-nonempty

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

#NonEmpty Source

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 Source

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

Create a non-empty structure with a single value.

#(:|) Source

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

An infix synonym for NonEmpty.

#foldl1 Source

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 Source

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

#oneOf Source

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

#head Source

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

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

#tail Source

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

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

Modules
Data.NonEmpty