Skip to content

Commit 03d4814

Browse files
committed
Add information about Array instances to Array docs
1 parent 931875a commit 03d4814

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Data/Array.purs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@
55
-- | use cases. This module is useful when integrating with JavaScript libraries
66
-- | which use arrays, but immutable arrays are not a practical data structure
77
-- | for many use cases due to their poor asymptotics.
8+
-- |
9+
-- | In addition to the functions in this module, Arrays have a number of
10+
-- | useful instances:
11+
-- |
12+
-- | * `Functor`, which provides `map :: forall a b. (a -> b) -> Array a ->
13+
-- | Array b`
14+
-- | * `Apply`, which provides `(<*>) :: forall a b. Array (a -> b) -> Array a
15+
-- | -> Array b`. This function works a bit like a Cartesian product; the
16+
-- | result array is constructed by applying each function in the first
17+
-- | array to each value in the second, so that the result array ends up with
18+
-- | a length equal to the product of the two arguments' lengths.
19+
-- | * `Bind`, which provides `(>>=) :: forall a b. (a -> Array b) -> Array a
20+
-- | -> Array b` (this is the same as `concatMap`).
21+
-- | * `Semigroup`, which provides `(<>) :: forall a. Array a -> Array a ->
22+
-- | Array a`, for concatenating arrays.
23+
-- | * `Foldable`, which provides a slew of functions for *folding* (also known
24+
-- | as *reducing*) arrays down to one value. For example,
25+
-- | `Data.Foldable.any` tests whether an array of `Boolean` values contains
26+
-- | at least one `true`.
27+
-- | * `Traversable`, which provides the PureScript version of a for-loop,
28+
-- | allowing you to iterate over an array and accumulate effects.
29+
-- |
830
module Data.Array
931
( singleton
1032
, (..), range

0 commit comments

Comments
 (0)