Module

Data.Array.NonEmpty

#fromArray

fromArray :: forall a. Array a -> Maybe (NonEmptyArray a)

#fromNonEmpty

#toArray

toArray :: forall a. NonEmptyArray a -> Array a

#toNonEmpty

#fromFoldable

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

#fromFoldable1

fromFoldable1 :: forall f a. Foldable1 f => f a -> NonEmptyArray a

#toUnfoldable

toUnfoldable :: forall f a. Unfoldable f => NonEmptyArray a -> f a

#toUnfoldable1

toUnfoldable1 :: forall f a. Unfoldable1 f => NonEmptyArray a -> f a

#singleton

singleton :: forall a. a -> NonEmptyArray a

#(..)

Operator alias for Data.Array.NonEmpty.range (non-associative / precedence 8)

#range

#replicate

replicate :: forall a. Int -> a -> NonEmptyArray a

Replicate an item at least once

#some

some :: forall f a. Alternative f => Lazy (f (Array a)) => f a -> f (NonEmptyArray a)

#length

length :: forall a. NonEmptyArray a -> Int

#(:)

Operator alias for Data.Array.NonEmpty.cons (right-associative / precedence 6)

#cons

cons :: forall a. a -> NonEmptyArray a -> NonEmptyArray a

#cons'

cons' :: forall a. a -> Array a -> NonEmptyArray a

#snoc

snoc :: forall a. NonEmptyArray a -> a -> NonEmptyArray a

#snoc'

snoc' :: forall a. Array a -> a -> NonEmptyArray a

#appendArray

appendArray :: forall a. NonEmptyArray a -> Array a -> NonEmptyArray a

#insert

insert :: forall a. Ord a => a -> NonEmptyArray a -> NonEmptyArray a

#insertBy

insertBy :: forall a. (a -> a -> Ordering) -> a -> NonEmptyArray a -> NonEmptyArray a

#head

head :: forall a. NonEmptyArray a -> a

#last

last :: forall a. NonEmptyArray a -> a

#tail

tail :: forall a. NonEmptyArray a -> Array a

#init

init :: forall a. NonEmptyArray a -> Array a

#uncons

uncons :: forall a. NonEmptyArray a -> { head :: a, tail :: Array a }

#unsnoc

unsnoc :: forall a. NonEmptyArray a -> { init :: Array a, last :: a }

#(!!)

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

#index

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

#elem

elem :: forall a. Eq a => a -> NonEmptyArray a -> Boolean

#notElem

notElem :: forall a. Eq a => a -> NonEmptyArray a -> Boolean

#elemIndex

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

#elemLastIndex

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

#find

find :: forall a. (a -> Boolean) -> NonEmptyArray a -> Maybe a

#findMap

findMap :: forall a b. (a -> Maybe b) -> NonEmptyArray a -> Maybe b

#findIndex

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

#findLastIndex

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

#insertAt

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

#deleteAt

deleteAt :: forall a. Int -> NonEmptyArray a -> Maybe (Array a)

#updateAt

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

#updateAtIndices

updateAtIndices :: forall t a. Foldable t => t (Tuple Int a) -> NonEmptyArray a -> NonEmptyArray a

#modifyAt

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

#modifyAtIndices

modifyAtIndices :: forall t a. Foldable t => t Int -> (a -> a) -> NonEmptyArray a -> NonEmptyArray a

#alterAt

alterAt :: forall a. Int -> (a -> Maybe a) -> NonEmptyArray a -> Maybe (Array a)

#intersperse

intersperse :: forall a. a -> NonEmptyArray a -> NonEmptyArray a

#reverse

reverse :: forall a. NonEmptyArray a -> NonEmptyArray a

#concat

#concatMap

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

#filter

filter :: forall a. (a -> Boolean) -> NonEmptyArray a -> Array a

#partition

partition :: forall a. (a -> Boolean) -> NonEmptyArray a -> { no :: Array a, yes :: Array a }

#splitAt

splitAt :: forall a. Int -> NonEmptyArray a -> { after :: Array a, before :: Array a }

#filterA

filterA :: forall a f. Applicative f => (a -> f Boolean) -> NonEmptyArray a -> f (Array a)

#mapMaybe

mapMaybe :: forall a b. (a -> Maybe b) -> NonEmptyArray a -> Array b

#catMaybes

catMaybes :: forall a. NonEmptyArray (Maybe a) -> Array a

#mapWithIndex

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

#foldl1

foldl1 :: forall a. (a -> a -> a) -> NonEmptyArray a -> a

#foldr1

foldr1 :: forall a. (a -> a -> a) -> NonEmptyArray a -> a

#foldMap1

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

#fold1

fold1 :: forall m. Semigroup m => NonEmptyArray m -> m

#intercalate

intercalate :: forall a. Semigroup a => a -> NonEmptyArray a -> a

#scanl

scanl :: forall a b. (b -> a -> b) -> b -> NonEmptyArray a -> NonEmptyArray b

#scanr

scanr :: forall a b. (a -> b -> b) -> b -> NonEmptyArray a -> NonEmptyArray b

#sort

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

#sortBy

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

#sortWith

sortWith :: forall a b. Ord b => (a -> b) -> NonEmptyArray a -> NonEmptyArray a

#slice

slice :: forall a. Int -> Int -> NonEmptyArray a -> Array a

#take

take :: forall a. Int -> NonEmptyArray a -> Array a

#takeEnd

takeEnd :: forall a. Int -> NonEmptyArray a -> Array a

#takeWhile

takeWhile :: forall a. (a -> Boolean) -> NonEmptyArray a -> Array a

#drop

drop :: forall a. Int -> NonEmptyArray a -> Array a

#dropEnd

dropEnd :: forall a. Int -> NonEmptyArray a -> Array a

#dropWhile

dropWhile :: forall a. (a -> Boolean) -> NonEmptyArray a -> Array a

#span

span :: forall a. (a -> Boolean) -> NonEmptyArray a -> { init :: Array a, rest :: Array a }

#group

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

Group equal, consecutive elements of an array into arrays.

group (NonEmptyArray [1, 1, 2, 2, 1]) ==
  NonEmptyArray [NonEmptyArray [1, 1], NonEmptyArray [2, 2], NonEmptyArray [1]]

#groupAll

groupAll :: forall a. Ord a => NonEmptyArray a -> NonEmptyArray (NonEmptyArray a)

Group equal elements of an array into arrays.

groupAll (NonEmptyArray [1, 1, 2, 2, 1]) ==
  NonEmptyArray [NonEmptyArray [1, 1, 1], NonEmptyArray [2, 2]]
`

#group'

group' :: forall a. Warn (Text "\'group\'\' is deprecated, use \'groupAll\' instead") => Ord a => NonEmptyArray a -> NonEmptyArray (NonEmptyArray a)

Deprecated previous name of groupAll.

#groupBy

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

Group equal, consecutive elements of an array into arrays, using the specified equivalence relation to determine equality.

groupBy (\a b -> odd a && odd b) (NonEmptyArray [1, 3, 2, 4, 3, 3])
   = NonEmptyArray [NonEmptyArray [1, 3], NonEmptyArray [2], NonEmptyArray [4], NonEmptyArray [3, 3]]

#groupAllBy

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

Group equal elements of an array into arrays, using the specified comparison function to determine equality.

groupAllBy (comparing Down) (NonEmptyArray [1, 3, 2, 4, 3, 3])
   = NonEmptyArray [NonEmptyArray [4], NonEmptyArray [3, 3, 3], NonEmptyArray [2], NonEmptyArray [1]]

#nub

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

#nubBy

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

#nubEq

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

#nubByEq

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

#union

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

#union'

union' :: forall a. Eq a => NonEmptyArray a -> Array a -> NonEmptyArray a

#unionBy

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

#unionBy'

unionBy' :: forall a. (a -> a -> Boolean) -> NonEmptyArray a -> Array a -> NonEmptyArray a

#delete

delete :: forall a. Eq a => a -> NonEmptyArray a -> Array a

#deleteBy

deleteBy :: forall a. (a -> a -> Boolean) -> a -> NonEmptyArray a -> Array a

#(\\)

Operator alias for Data.Array.NonEmpty.difference (non-associative / precedence 5)

#difference

difference :: forall a. Eq a => NonEmptyArray a -> NonEmptyArray a -> Array a

#difference'

difference' :: forall a. Eq a => NonEmptyArray a -> Array a -> Array a

#intersect

intersect :: forall a. Eq a => NonEmptyArray a -> NonEmptyArray a -> Array a

#intersect'

intersect' :: forall a. Eq a => NonEmptyArray a -> Array a -> Array a

#intersectBy

intersectBy :: forall a. (a -> a -> Boolean) -> NonEmptyArray a -> NonEmptyArray a -> Array a

#intersectBy'

intersectBy' :: forall a. (a -> a -> Boolean) -> NonEmptyArray a -> Array a -> Array a

#zipWith

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

#zipWithA

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

#zip

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

#unzip

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

#any

any :: forall a. (a -> Boolean) -> NonEmptyArray a -> Boolean

#all

all :: forall a. (a -> Boolean) -> NonEmptyArray a -> Boolean

#foldM

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

#foldRecM

foldRecM :: forall m a b. MonadRec m => (b -> a -> m b) -> b -> NonEmptyArray a -> m b

#unsafeIndex

unsafeIndex :: forall a. Partial => NonEmptyArray a -> Int -> a

Re-exports from Data.Array.NonEmpty.Internal

#NonEmptyArray

newtype NonEmptyArray a

An array that is known not to be empty.

You can use the constructor to create a NonEmptyArray that isn't non-empty, breaking the guarantee behind this newtype. It is provided as an escape hatch mainly for the Data.Array.NonEmpty and Data.Array modules. Use this at your own risk when you know what you are doing.

Instances

Modules