-
Notifications
You must be signed in to change notification settings - Fork 69
Improve docs #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs #52
Changes from 5 commits
c1f2d68
931875a
03d4814
fc775d1
9891cd1
5ac412b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| language: node_js | ||
| sudo: false | ||
| node_js: | ||
| - 0.10 | ||
| - 4.2 | ||
| - 5.2 | ||
| env: | ||
| - PATH=$HOME/purescript:$PATH | ||
| install: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,12 +8,36 @@ use cases. This module is useful when integrating with JavaScript libraries | |
| which use arrays, but immutable arrays are not a practical data structure | ||
| for many use cases due to their poor asymptotics. | ||
|
|
||
| In addition to the functions in this module, Arrays have a number of | ||
| useful instances: | ||
|
|
||
| * `Functor`, which provides `map :: forall a b. (a -> b) -> Array a -> | ||
| Array b` | ||
| * `Apply`, which provides `(<*>) :: forall a b. Array (a -> b) -> Array a | ||
| -> Array b`. This function works a bit like a Cartesian product; the | ||
| result array is constructed by applying each function in the first | ||
| array to each value in the second, so that the result array ends up with | ||
| a length equal to the product of the two arguments' lengths. | ||
| * `Bind`, which provides `(>>=) :: forall a b. (a -> Array b) -> Array a | ||
| -> Array b` (this is the same as `concatMap`). | ||
| * `Semigroup`, which provides `(<>) :: forall a. Array a -> Array a -> | ||
| Array a`, for concatenating arrays. | ||
| * `Foldable`, which provides a slew of functions for *folding* (also known | ||
| as *reducing*) arrays down to one value. For example, | ||
| `Data.Foldable.any` tests whether an array of `Boolean` values contains | ||
| at least one `true`. | ||
| * `Traversable`, which provides the PureScript version of a for-loop, | ||
| allowing you to iterate over an array and accumulate effects. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, had another thought. Perhaps we could make these link to the appropriate classes rather than having to include types, etc? Or maybe both if you think it's useful to include this info here as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That [edit: linking] would be nice, but we'd have to choose a specific version of prelude/foldable-traversable to link to, which might cause problems if things change. These particular classes probably won't change that much, but other stuff in those packages might. I had beginners in mind in particular with this paragraph, or rather, people who aren't yet familiar with all of these type classes. For example, I've encountered people more than once in IRC who were confused about why
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok. I kinda assumed you could leave the version out of the URL and it would redirect to the latest, the way it does for the package route. But that wouldn't help anyway if things moved around. Makes sense.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think giving people a way of linking to a particular type in the documentation could be really nice, but I haven't quite figured out how to do it well just yet. |
||
|
|
||
| #### `singleton` | ||
|
|
||
| ``` purescript | ||
| singleton :: forall a. a -> Array a | ||
| ``` | ||
|
|
||
| Create an array of one element | ||
|
|
||
| #### `range` | ||
|
|
||
| ``` purescript | ||
|
|
@@ -453,7 +477,7 @@ specified equivalence relation to detemine equality. | |
| nub :: forall a. (Eq a) => Array a -> Array a | ||
| ``` | ||
|
|
||
| Special case of `nubBy`: `nubBy eq` | ||
| Remove the duplicates from an array, creating a new array. | ||
|
|
||
| #### `nubBy` | ||
|
|
||
|
|
@@ -462,8 +486,7 @@ nubBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a | |
| ``` | ||
|
|
||
| Remove the duplicates from an array, where element equality is determined | ||
| by the specified equivalence relation, creating a new array. The first | ||
| occurence of an element is always the one that is kept. | ||
| by the specified equivalence relation, creating a new array. | ||
|
|
||
| #### `union` | ||
|
|
||
|
|
@@ -537,6 +560,17 @@ relation to compare elements, creating a new array. | |
| zipWith :: forall a b c. (a -> b -> c) -> Array a -> Array b -> Array c | ||
| ``` | ||
|
|
||
| Apply a function to pairs of elements at the same index in two arrays, | ||
| collecting the results in a new array. | ||
|
|
||
| If one array is longer, elements will be discarded from the longer array. | ||
|
|
||
| For example | ||
|
|
||
| ```purescript | ||
| zipWith (*) [1, 2, 3] [4, 5, 6, 7] == [4, 10, 18] | ||
| ``` | ||
|
|
||
| #### `zipWithA` | ||
|
|
||
| ``` purescript | ||
|
|
@@ -569,3 +603,7 @@ second components. | |
| ``` purescript | ||
| foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> Array b -> m a | ||
| ``` | ||
|
|
||
| Perform a fold using a monadic step function. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth just specifying
4and5here so the latest point release of each is used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware you could do that! Definitely sounds sensible. Will do.