Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module provides a way to lift potentially empty structures into one which is guaranteed to be NonEmpty by construction.
Synopsis
- data NonEmpty f a = NonEmpty a (f a)
- head :: NonEmpty f a -> a
- tail :: NonEmpty f a -> f a
- toList :: Foldable f => NonEmpty f a -> [a]
- zip :: MonadZip f => NonEmpty f a -> NonEmpty f b -> NonEmpty f (a, b)
- zipWith :: MonadZip f => (a -> b -> c) -> NonEmpty f a -> NonEmpty f b -> NonEmpty f c
- unzip :: Functor f => NonEmpty f (a, b) -> (NonEmpty f a, NonEmpty f b)
- nonEmpty :: a -> f a -> NonEmpty f a
Documentation
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.
NonEmpty a (f a) |
Instances
zip :: MonadZip f => NonEmpty f a -> NonEmpty f b -> NonEmpty f (a, b) Source #
Zip two NonEmpty
s together.