Module

Data.List.NonEmpty

Package
purescript-lists
Repository
purescript/purescript-lists

#toUnfoldable Source

#fromFoldable Source

fromFoldable :: forall a f. 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

#cons Source

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

#snoc Source

snoc :: forall a. NonEmptyList 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 }

#length Source

length :: forall a. NonEmptyList a -> Int

#index Source

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

#(!!) Source

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

#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

#filter Source

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

#filterM Source

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

#mapMaybe Source

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

#catMaybes Source

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

#concatMap Source

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

#appendFoldable Source

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

#mapWithIndex Source

mapWithIndex :: forall b a. (Int -> a -> b) -> NonEmptyList a -> NonEmptyList b

#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)

#group' Source

group' :: forall a. Ord a => NonEmptyList a -> NonEmptyList (NonEmptyList a)

#groupBy Source

groupBy :: forall a. (a -> a -> Boolean) -> 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. Eq a => NonEmptyList a -> NonEmptyList a

#nubBy Source

nubBy :: 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 c b a. (a -> b -> c) -> NonEmptyList a -> NonEmptyList b -> NonEmptyList c

#zipWithA Source

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

#zip Source

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

#unzip Source

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

#foldM Source

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

Re-exports from Data.Foldable

#foldMap

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

#foldl

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

#foldr

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

#notElem

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

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

#intercalate

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

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

#fold

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

Fold a data structure, accumulating values in some Monoid.

#findMap

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

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

#find

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

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

#elem

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

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

#any

any :: forall f b a. 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

all :: forall f b a. 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

#fold1

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

#foldMap1

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

#traverse1_

traverse1_ :: forall b a f t. 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_

sequence1_ :: forall a f t. 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_

for1_ :: forall b a f t. 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:

Re-exports from Data.Semigroup.Traversable

#sequence1

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

#traverse1

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

#traverse1Default

traverse1Default :: forall m b a t. 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

scanr :: forall f b a. 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] = [1,3,6]
scanr (flip (-)) 10 [1,2,3] = [4,5,7]

#scanl

scanl :: forall f b a. 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]