DA.NonEmpty
Type and functions for non-empty lists. This module re-exports many functions with the same name as prelude list functions, so it is expected to import the module qualified. For example, with the following import list you will have access to theNonEmpty type
and any functions on non-empty lists will be qualified, for example as NE.append, NE.map, NE.foldl:
Module Snapshot
Lifecycle
Stable.
Notices
Status:
active
Introduced in: 3.4.9
Removed in: -
Warnings: 0
Deprecations: 0
Deprecated since: -Functions
cons
cons : a -> NonEmpty a -> NonEmpty a
Prepend an element to a non-empty list.
append
append : NonEmpty a -> NonEmpty a -> NonEmpty a
Append or concatenate two non-empty lists.
map
map : (a -> b) -> NonEmpty a -> NonEmpty b
Apply a function over each element in the non-empty list.
nonEmpty
nonEmpty : [a] -> Optional (NonEmpty a)
Turn a list into a non-empty list, if possible. Returns
None if the input list is empty, and Some otherwise.
singleton
singleton : a -> NonEmpty a
A non-empty list with a single element.
toList
toList : NonEmpty a -> [a]
Turn a non-empty list into a list (by forgetting that it is not empty).
reverse
reverse : NonEmpty a -> NonEmpty a
Reverse a non-empty list.
find
find : (a -> Bool) -> NonEmpty a -> Optional a
Find an element in a non-empty list.
deleteBy
deleteBy : (a -> a -> Bool) -> a -> NonEmpty a -> [a]
The ‘deleteBy’ function behaves like ‘delete’, but takes a
user-supplied equality predicate.
delete
delete : Eq a => a -> NonEmpty a -> [a]
Remove the first occurence of x from the non-empty list, potentially
removing all elements.
foldl1
foldl1 : (a -> a -> a) -> NonEmpty a -> a
Apply a function repeatedly to pairs of elements from a non-empty list,
from the left. For example, foldl1 (+) (NonEmpty 1 [2,3,4]) = ((1 + 2) + 3) + 4.
foldr1
foldr1 : (a -> a -> a) -> NonEmpty a -> a
Apply a function repeatedly to pairs of elements from a non-empty list,
from the right. For example, foldr1 (+) (NonEmpty 1 [2,3,4]) = 1 + (2 + (3 + 4)).
foldr
foldr : (a -> b -> b) -> b -> NonEmpty a -> b
Apply a function repeatedly to pairs of elements from a non-empty list,
from the right, with a given initial value. For example,
foldr (+) 0 (NonEmpty 1 [2,3,4]) = 1 + (2 + (3 + (4 + 0))).
foldrA
foldrA : Action m => (a -> b -> m b) -> b -> NonEmpty a -> m b
The same as foldr but running an action each time.
foldr1A
foldr1A : Action m => (a -> a -> m a) -> NonEmpty a -> m a
The same as foldr1 but running an action each time.
foldl
foldl : (b -> a -> b) -> b -> NonEmpty a -> b
Apply a function repeatedly to pairs of elements from a non-empty list,
from the left, with a given initial value. For example,
foldl (+) 0 (NonEmpty 1 [2,3,4]) = (((0 + 1) + 2) + 3) + 4.
foldlA
foldlA : Action m => (b -> a -> m b) -> b -> NonEmpty a -> m b
The same as foldl but running an action each time.
foldl1A
foldl1A : Action m => (a -> a -> m a) -> NonEmpty a -> m a
The same as foldl1 but running an action each time.
Orphan Typeclass Instances
-
instance
Eqa=>Eq(NonEmptya) -
instance
Showa=>Show(NonEmptya) -
instance
Orda=>Ord(NonEmptya) -
instance
GetFieldhd(NonEmptya)a -
instance
SetFieldhd(NonEmptya)a -
instance
GetFieldtl(NonEmptya) [a] -
instance
SetFieldtl(NonEmptya) [a] -
instance
Semigroup(NonEmptya) -
instance
FunctorNonEmpty -
instance
ApplicativeNonEmpty -
instance
ActionNonEmpty -
instance
FoldableNonEmpty -
instance
TraversableNonEmpty -
instance
IsParties(NonEmptyParty)