Module

Data.ArrayView

Package
purescript-array-views
Repository
klntsky/purescript-array-views

#fromFoldable Source

fromFoldable :: forall f. Foldable f => f ~> ArrayView

#toUnfoldable Source

toUnfoldable :: forall f. Unfoldable f => ArrayView ~> f

#(..) Source

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

#replicate Source

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

#some Source

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

#many Source

many :: forall a f. Alternative f => Lazy (f (Array a)) => f a -> f (ArrayView a)

#null Source

null :: forall a. ArrayView a -> Boolean

#(:) Source

Operator alias for Data.ArrayView.cons (non-associative / precedence 6)

#cons Source

cons :: forall a. a -> ArrayView a -> ArrayView a

O(n)

#snoc Source

snoc :: forall a. ArrayView a -> a -> ArrayView a

O(n)

#insert Source

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

#insertBy Source

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

#head Source

head :: forall a. ArrayView a -> Maybe a

#last Source

last :: forall a. ArrayView a -> Maybe a

#tail Source

tail :: forall a. ArrayView a -> Maybe (ArrayView a)

O(1)

#init Source

init :: forall a. ArrayView a -> Maybe (ArrayView a)

O(1)

#uncons Source

uncons :: forall a. ArrayView a -> Maybe { head :: a, tail :: ArrayView a }

O(1)

#unsnoc Source

unsnoc :: forall a. ArrayView a -> Maybe { init :: ArrayView a, last :: a }

O(1)

#elemIndex Source

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

#elemLastIndex Source

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

#findIndex Source

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

#findLastIndex Source

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

#insertAt Source

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

#deleteAt Source

deleteAt :: forall a. Int -> ArrayView a -> Maybe (ArrayView a)

#updateAt Source

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

#updateAtIndices Source

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

#modifyAt Source

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

#modifyAtIndices Source

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

#alterAt Source

alterAt :: forall a. Int -> (a -> Maybe a) -> ArrayView a -> Maybe (ArrayView a)

#reverse Source

reverse :: forall a. ArrayView a -> ArrayView a

#concat Source

concat :: forall a. ArrayView (ArrayView a) -> ArrayView a

#filter Source

filter :: forall a. (a -> Boolean) -> ArrayView a -> ArrayView a

#partition Source

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

#filterA Source

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

#mapMaybe Source

mapMaybe :: forall b a. (a -> Maybe b) -> ArrayView a -> ArrayView b

#catMaybes Source

catMaybes :: forall a. ArrayView (Maybe a) -> ArrayView a

#mapWithIndex Source

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

#sort Source

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

#sortBy Source

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

#sortWith Source

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

#slice Source

slice :: forall a. Int -> Int -> ArrayView a -> ArrayView a

O(1)

#take Source

take :: forall a. Int -> ArrayView a -> ArrayView a

O(1)

#takeEnd Source

takeEnd :: forall a. Int -> ArrayView a -> ArrayView a

O(1)

#takeWhile Source

takeWhile :: forall a. (a -> Boolean) -> ArrayView a -> ArrayView a

See also: span.

#drop Source

drop :: forall a. Int -> ArrayView a -> ArrayView a

O(1)

#dropEnd Source

dropEnd :: forall a. Int -> ArrayView a -> ArrayView a

O(1)

#dropWhile Source

dropWhile :: forall a. (a -> Boolean) -> ArrayView a -> ArrayView a

See also: span.

#span Source

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

The time complexity of span only depends on the length of the resulting init ArrayView.

#group Source

group :: forall a. Eq a => ArrayView a -> ArrayView (NonEmptyArrayView a)

#group' Source

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

#groupBy Source

groupBy :: forall a. (a -> a -> Boolean) -> ArrayView a -> ArrayView (NonEmptyArrayView a)

#nub Source

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

#nubEq Source

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

#nubBy Source

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

#nubByEq Source

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

#union Source

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

#unionBy Source

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

#delete Source

delete :: forall a. Eq a => a -> ArrayView a -> ArrayView a

#deleteBy Source

deleteBy :: forall a. (a -> a -> Boolean) -> a -> ArrayView a -> ArrayView a

#(\\) Source

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

#difference Source

difference :: forall a. Eq a => ArrayView a -> ArrayView a -> ArrayView a

#intersect Source

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

#intersectBy Source

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

#zipWith Source

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

#zipWithA Source

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

#zip Source

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

#unzip Source

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

#foldM Source

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

#foldRecM Source

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

#unsafeIndex Source

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

#force Source

force :: forall a. ArrayView a -> ArrayView a

Perform deferred slice. This function allows the garbage collector to free unused parts of the array referenced by given ArrayView.

O(n)

force = toArray >>> fromArray

Re-exports from Data.ArrayView.Internal

#ArrayToView Source

class ArrayToView a b  where

This typeclass allows to convert any function that operates on Array to a function that operates on ArrayView and vice versa. use only inserts fromArray and toArray in the right places, so don't expect it to increase performance.

Note: either type annotation or partial application of some number of arguments is needed, because otherwise the type inference will not be able to guess the correct type.

import Data.Array as A

-- OK
zipWith :: forall a b c. (a -> b -> c) -> ArrayView a -> ArrayView b -> ArrayView c
zipWith = use (A.zipWith :: (a -> b -> c) -> Array a -> Array b -> Array c)

-- OK
zipWith :: forall a b c. (a -> b -> c) -> ArrayView a -> ArrayView b -> ArrayView c
zipWith f = use (A.zipWith f) -- all three type parameters are tied to `f`

-- Type error
zipWith :: forall a b c. (a -> b -> c) -> ArrayView a -> ArrayView b -> ArrayView c
zipWith = use A.zipWith

Members

Instances

#singleton Source

singleton :: forall a. a -> ArrayView a

#length Source

length :: forall a. ArrayView a -> Int

#index Source

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

#concatMap Source

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

#(!!) Source

Operator alias for Data.ArrayView.Internal.index (left-associative / precedence 8)

Re-exports from Data.Foldable

#foldMap Source

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

#foldl Source

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

#foldr Source

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

#notElem Source

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 Source

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.

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 m f. Foldable f => Monoid m => f m -> m

Fold a data structure, accumulating values in some Monoid.

#findMap Source

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 Source

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 Source

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

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

#any Source

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 Source

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.Traversable

#scanr Source

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] = [6,5,3]
scanr (flip (-)) 10 [1,2,3] = [4,5,7]

#scanl Source

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]