@@ -8,12 +8,36 @@ use cases. This module is useful when integrating with JavaScript libraries
88which use arrays, but immutable arrays are not a practical data structure
99for many use cases due to their poor asymptotics.
1010
11+ In addition to the functions in this module, Arrays have a number of
12+ useful instances:
13+
14+ * ` Functor ` , which provides `map :: forall a b. (a -> b) -> Array a ->
15+ Array b`
16+ * ` Apply ` , which provides `(<* >) :: forall a b. Array (a -> b) -> Array a
17+ -> Array b`. This function works a bit like a Cartesian product; the
18+ result array is constructed by applying each function in the first
19+ array to each value in the second, so that the result array ends up with
20+ a length equal to the product of the two arguments' lengths.
21+ * ` Bind ` , which provides `(>>=) :: forall a b. (a -> Array b) -> Array a
22+ -> Array b` (this is the same as ` concatMap`).
23+ * ` Semigroup ` , which provides `(<>) :: forall a. Array a -> Array a ->
24+ Array a`, for concatenating arrays.
25+ * ` Foldable ` , which provides a slew of functions for * folding* (also known
26+ as * reducing* ) arrays down to one value. For example,
27+ ` Data.Foldable.any ` tests whether an array of ` Boolean ` values contains
28+ at least one ` true ` .
29+ * ` Traversable ` , which provides the PureScript version of a for-loop,
30+ allowing you to iterate over an array and accumulate effects.
31+
32+
1133#### ` singleton `
1234
1335``` purescript
1436singleton :: forall a. a -> Array a
1537```
1638
39+ Create an array of one element
40+
1741#### ` range `
1842
1943``` purescript
@@ -453,7 +477,7 @@ specified equivalence relation to detemine equality.
453477nub :: forall a. (Eq a) => Array a -> Array a
454478```
455479
456- Special case of ` nubBy ` : ` nubBy eq `
480+ Remove the duplicates from an array, creating a new array.
457481
458482#### ` nubBy `
459483
@@ -462,8 +486,7 @@ nubBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a
462486```
463487
464488Remove the duplicates from an array, where element equality is determined
465- by the specified equivalence relation, creating a new array. The first
466- occurence of an element is always the one that is kept.
489+ by the specified equivalence relation, creating a new array.
467490
468491#### ` union `
469492
@@ -537,6 +560,17 @@ relation to compare elements, creating a new array.
537560zipWith :: forall a b c. (a -> b -> c) -> Array a -> Array b -> Array c
538561```
539562
563+ Apply a function to pairs of elements at the same index in two arrays,
564+ collecting the results in a new array.
565+
566+ If one array is longer, elements will be discarded from the longer array.
567+
568+ For example
569+
570+ ``` purescript
571+ zipWith (*) [1, 2, 3] [4, 5, 6, 7] == [4, 10, 18]
572+ ```
573+
540574#### ` zipWithA `
541575
542576``` purescript
@@ -569,3 +603,7 @@ second components.
569603``` purescript
570604foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> Array b -> m a
571605```
606+
607+ Perform a fold using a monadic step function.
608+
609+
0 commit comments