Module

Data.List.NonEmpty

Package
purescript-lists
Repository
purescript/purescript-lists

#toUnfoldable Source

#fromFoldable Source

fromFoldable :: forall f a. Foldable f => f a -> Maybe (NonEmptyList a)

#fromList Source

fromList :: forall a. List a -> Maybe (NonEmptyList a)

#singleton Source

singleton :: forall a. a -> NonEmptyList a

#length Source

length :: forall a. NonEmptyList a -> Int

#cons Source

cons :: forall a. a -> NonEmptyList a -> NonEmptyList a

#cons' Source

cons' :: forall a. a -> List a -> NonEmptyList a

#snoc Source

snoc :: forall a. NonEmptyList a -> a -> NonEmptyList a

#snoc' Source

snoc' :: forall a. List a -> a -> NonEmptyList a

#head Source

head :: forall a. NonEmptyList a -> a

#last Source

last :: forall a. NonEmptyList a -> a

#uncons Source

uncons :: forall a. NonEmptyList a -> { head :: a, tail :: List a }

#unsnoc Source

unsnoc :: forall a. NonEmptyList a -> { init :: List a, last :: a }

#(!!) Source

Operator alias for Data.List.NonEmpty.index (left-associative / precedence 8)

#index Source

index :: forall a. NonEmptyList a -> Int -> Maybe a

#elemIndex Source

elemIndex :: forall a. Eq a => a -> NonEmptyList a -> Maybe Int

#elemLastIndex Source

elemLastIndex :: forall a. Eq a => a -> NonEmptyList a -> Maybe Int

#findIndex Source

findIndex :: forall a. (a -> Boolean) -> NonEmptyList a -> Maybe Int

#findLastIndex Source

findLastIndex :: forall a. (a -> Boolean) -> NonEmptyList a -> Maybe Int

#insertAt Source

insertAt :: forall a. Int -> a -> NonEmptyList a -> Maybe (NonEmptyList a)

#updateAt Source

updateAt :: forall a. Int -> a -> NonEmptyList a -> Maybe (NonEmptyList a)

#modifyAt Source

modifyAt :: forall a. Int -> (a -> a) -> NonEmptyList a -> Maybe (NonEmptyList a)

#reverse Source

reverse :: forall a. NonEmptyList a -> NonEmptyList a

#concatMap Source

concatMap :: forall a b. (a -> NonEmptyList b) -> NonEmptyList a -> NonEmptyList b

#filter Source

filter :: forall a. (a -> Boolean) -> NonEmptyList a -> List a

#filterM Source

filterM :: forall m a. Monad m => (a -> m Boolean) -> NonEmptyList a -> m (List a)

#mapMaybe Source

mapMaybe :: forall a b. (a -> Maybe b) -> NonEmptyList a -> List b

#catMaybes Source

catMaybes :: forall a. NonEmptyList (Maybe a) -> List a

#appendFoldable Source

appendFoldable :: forall t a. Foldable t => NonEmptyList a -> t a -> NonEmptyList a

#sort Source

sort :: forall a. Ord a => NonEmptyList a -> NonEmptyList a

#sortBy Source

sortBy :: forall a. (a -> a -> Ordering) -> NonEmptyList a -> NonEmptyList a

#take Source

take :: forall a. Int -> NonEmptyList a -> List a

#takeWhile Source

takeWhile :: forall a. (a -> Boolean) -> NonEmptyList a -> List a

#drop Source

drop :: forall a. Int -> NonEmptyList a -> List a

#dropWhile Source

dropWhile :: forall a. (a -> Boolean) -> NonEmptyList a -> List a

#span Source

span :: forall a. (a -> Boolean) -> NonEmptyList a -> { init :: List a, rest :: List a }

#group Source

group :: forall a. Eq a => NonEmptyList a -> NonEmptyList (NonEmptyList a)

#groupAll Source

#groupBy Source

groupBy :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList (NonEmptyList a)

#groupAllBy Source

groupAllBy :: forall a. (a -> a -> Ordering) -> NonEmptyList a -> NonEmptyList (NonEmptyList a)

#partition Source

partition :: forall a. (a -> Boolean) -> NonEmptyList a -> { no :: List a, yes :: List a }

#nub Source

nub :: forall a. Ord a => NonEmptyList a -> NonEmptyList a

#nubBy Source

nubBy :: forall a. (a -> a -> Ordering) -> NonEmptyList a -> NonEmptyList a

#nubEq Source

nubEq :: forall a. Eq a => NonEmptyList a -> NonEmptyList a

#nubByEq Source

nubByEq :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList a

#union Source

union :: forall a. Eq a => NonEmptyList a -> NonEmptyList a -> NonEmptyList a

#unionBy Source

unionBy :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList a -> NonEmptyList a

#intersect Source

intersect :: forall a. Eq a => NonEmptyList a -> NonEmptyList a -> NonEmptyList a

#intersectBy Source

intersectBy :: forall a. (a -> a -> Boolean) -> NonEmptyList a -> NonEmptyList a -> NonEmptyList a

#zipWith Source

zipWith :: forall a b c. (a -> b -> c) -> NonEmptyList a -> NonEmptyList b -> NonEmptyList c

#zipWithA Source

zipWithA :: forall m a b c. Applicative m => (a -> b -> m c) -> NonEmptyList a -> NonEmptyList b -> m (NonEmptyList c)

#zip Source

zip :: forall a b. NonEmptyList a -> NonEmptyList b -> NonEmptyList (Tuple a b)

#unzip Source

unzip :: forall a b. NonEmptyList (Tuple a b) -> Tuple (NonEmptyList a) (NonEmptyList b)

#foldM Source

foldM :: forall m a b. Monad m => (b -> a -> m b) -> b -> NonEmptyList a -> m b

Re-exports from Data.Foldable

#foldMap Source

foldMap :: forall f a m. Foldable f => Monoid m => (a -> m) -> f a -> m

#foldl Source

foldl :: forall f a b. Foldable f => (b -> a -> b) -> b -> f a -> b

#foldr Source

foldr :: forall f a b. Foldable f => (a -> b -> b) -> b -> f a -> b

#notElem Source

notElem :: forall a f. Foldable f => Eq a => a -> f a -> Boolean

Test whether a value is not an element of a data structure.

#intercalate Source

intercalate :: forall f m. Foldable f => Monoid m => m -> f m -> m

Fold a data structure, accumulating values in some Monoid, combining adjacent elements using the specified separator.

For example:

> intercalate ", " ["Lorem", "ipsum", "dolor"]
= "Lorem, ipsum, dolor"

> intercalate "*" ["a", "b", "c"]
= "a*b*c"

> intercalate [1] [[2, 3], [4, 5], [6, 7]]
= [2, 3, 1, 4, 5, 1, 6, 7]

#fold Source

fold :: forall f m. Foldable f => Monoid m => f m -> m

Fold a data structure, accumulating values in some Monoid.

#findMap Source

findMap :: forall a b f. Foldable f => (a -> Maybe b) -> f a -> Maybe b

Try to find an element in a data structure which satisfies a predicate mapping.

#find Source

find :: forall a f. Foldable f => (a -> Boolean) -> f a -> Maybe a

Try to find an element in a data structure which satisfies a predicate.

#elem Source

elem :: forall a f. Foldable f => Eq a => a -> f a -> Boolean

Test whether a value is an element of a data structure.

#any Source

any :: forall a b f. Foldable f => HeytingAlgebra b => (a -> b) -> f a -> b

any f is the same as or <<< map f; map a function over the structure, and then get the disjunction of the results.

#all Source

all :: forall a b f. Foldable f => HeytingAlgebra b => (a -> b) -> f a -> b

all f is the same as and <<< map f; map a function over the structure, and then get the conjunction of the results.

Re-exports from Data.List.Types

Re-exports from Data.Semigroup.Foldable

#foldMap1 Source

foldMap1 :: forall t a m. Foldable1 t => Semigroup m => (a -> m) -> t a -> m

#traverse1_ Source

traverse1_ :: forall t f a b. Foldable1 t => Apply f => (a -> f b) -> t a -> f Unit

Traverse a data structure, performing some effects encoded by an Apply instance at each value, ignoring the final result.

#sequence1_ Source

sequence1_ :: forall t f a. Foldable1 t => Apply f => t (f a) -> f Unit

Perform all of the effects in some data structure in the order given by the Foldable1 instance, ignoring the final result.

#for1_ Source

for1_ :: forall t f a b. Foldable1 t => Apply f => t a -> (a -> f b) -> f Unit

A version of traverse1_ with its arguments flipped.

This can be useful when running an action written using do notation for every element in a data structure:

#fold1 Source

fold1 :: forall t m. Foldable1 t => Semigroup m => t m -> m

Fold a data structure, accumulating values in some Semigroup.

Re-exports from Data.Semigroup.Traversable

#sequence1 Source

sequence1 :: forall t b f. Traversable1 t => Apply f => t (f b) -> f (t b)

#traverse1 Source

traverse1 :: forall t a b f. Traversable1 t => Apply f => (a -> f b) -> t a -> f (t b)

#traverse1Default Source

traverse1Default :: forall t a b m. Traversable1 t => Apply m => (a -> m b) -> t a -> m (t b)

A default implementation of traverse1 using sequence1.

Re-exports from Data.Traversable

#scanr Source

scanr :: forall a b f. Traversable f => (a -> b -> b) -> b -> f a -> f b

Fold a data structure from the right, keeping all intermediate results instead of only the final result. Note that the initial value does not appear in the result (unlike Haskell's Prelude.scanr).

scanr (+) 0 [1,2,3] = [6,5,3]
scanr (flip (-)) 10 [1,2,3] = [4,5,7]

#scanl Source

scanl :: forall a b f. Traversable f => (b -> a -> b) -> b -> f a -> f b

Fold a data structure from the left, keeping all intermediate results instead of only the final result. Note that the initial value does not appear in the result (unlike Haskell's Prelude.scanl).

scanl (+) 0  [1,2,3] = [1,3,6]
scanl (-) 10 [1,2,3] = [9,7,4]