nonempty-lift-0.1: nonempty structure

NonEmpty

Description

This module provides a way to lift potentially empty structures into one which is guaranteed to be NonEmpty by construction.

Synopsis

# Documentation

data NonEmpty f a Source #

A structure which is nonempty by construction.

Typically this will be used to construct list-like structures; e.g.

• NonEmpty [] a is a lazy list containing at least one element.
• NonEmpty (NonEmpty []) a is a lazy list containing at least two elements.
• NonEmpty Maybe a is a list that contains one or two elements.

Constructors

 NonEmpty a (f a)
Instances

head :: NonEmpty f a -> a Source #

Get the head of a NonEmpty.

tail :: NonEmpty f a -> f a Source #

Get the tail of a NonEmpty.

toList :: Foldable f => NonEmpty f a -> [a] Source #

Convert a NonEmpty into a list.

zip :: MonadZip f => NonEmpty f a -> NonEmpty f b -> NonEmpty f (a, b) Source #

Zip two NonEmptys together.

zipWith :: MonadZip f => (a -> b -> c) -> NonEmpty f a -> NonEmpty f b -> NonEmpty f c Source #

Zip two NonEmptys together with a combining function.

unzip :: Functor f => NonEmpty f (a, b) -> (NonEmpty f a, NonEmpty f b) Source #

Unzip a NonEmpty.

nonEmpty :: a -> f a -> NonEmpty f a Source #

Construct a NonEmpty.