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

#(:|) Source

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

An infix synonym for NonEmpty.

#singleton Source

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

Create a non-empty structure with a single value.

#foldl1 Source

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

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

#foldMap1 Source

foldMap1 :: forall s a f. Semigroup s => Foldable f => (a -> s) -> NonEmpty f a -> s

Fold a non-empty structure, collecting results in a Semigroup.

#fold1 Source

fold1 :: forall s f. Semigroup s => Foldable f => NonEmpty f s -> s

Fold a non-empty structure.

#fromNonEmpty Source

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

#oneOf Source

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

#head Source

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

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

#tail Source

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

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

Modules
Data.NonEmpty