A type-safe list that has at least one element.
- data NonEmpty a
- neHead :: NonEmpty a -> a
- neTail :: NonEmpty a -> [a]
- nonEmpty :: a -> [a] -> NonEmpty a
- (|:) :: a -> [a] -> NonEmpty a
- toNonEmpty :: [a] -> Maybe (NonEmpty a)
- toNonEmpty' :: NonEmpty a -> [a] -> NonEmpty a
- unsafeToNonEmpty :: [a] -> NonEmpty a
- (.:) :: a -> NonEmpty a -> NonEmpty a
- reverse :: NonEmpty a -> NonEmpty a
- scanl :: (b -> a -> b) -> b -> NonEmpty a -> NonEmpty b
- scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
- scanr :: (a -> b -> b) -> b -> NonEmpty a -> NonEmpty b
- scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
- iterate :: (a -> a) -> a -> NonEmpty a
- cycle :: Foldable f => f a -> NonEmpty a
- inits :: [a] -> NonEmpty [a]
- tails :: [a] -> NonEmpty [a]
- sort :: Ord a => NonEmpty a -> NonEmpty a
- insert :: Ord a => a -> NonEmpty a -> NonEmpty a
- unzip :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b)
Documentation
A list with at least one element.
Monad NonEmpty | |
Functor NonEmpty | |
Typeable1 NonEmpty | |
Applicative NonEmpty | |
Foldable NonEmpty | |
Traversable NonEmpty | |
Zip NonEmpty | |
Comonad NonEmpty | |
Pointed NonEmpty | |
Copointed NonEmpty | |
Eq a => Eq (NonEmpty a) | |
Data a => Data (NonEmpty a) | |
Ord a => Ord (NonEmpty a) | |
Show a => Show (NonEmpty a) | |
Arbitrary a => Arbitrary (NonEmpty a) | |
Semigroup (NonEmpty a) |
Accessors
Constructors
:: a | The head. |
-> [a] | The tail. |
-> NonEmpty a |
Constructs a non-empty list with the given head and tail.
:: a | The head. |
-> [a] | The tail. |
-> NonEmpty a |
Constructs a non-empty list with the given head and tail (an alias for nonEmpty
).
Tries to convert a list to a NonEmpty
returning Nothing
if the given list is empty.
:: NonEmpty a | The default return value if the given list is empty. |
-> [a] | The list to convert. |
-> NonEmpty a |
Converts a list to a NonEmpty
using the given default value for the empty list case.
:: [a] | The list to convert (must not be empty). |
-> NonEmpty a |
WARNING: Fails if given the empty list.
Tries to convert a list to a NonEmpty
.
Prepends a value to a non-empty list.
List functions
Reverses the elements of the (finite) non-empty list.