Skip to content

Commit

Permalink
Move comparison to other languages to vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Mar 21, 2017
1 parent 34147b5 commit 011e690
Show file tree
Hide file tree
Showing 50 changed files with 310 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.Rproj.user
.Rhistory
.RData
inst/doc
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ Suggests:
covr,
dplyr (>= 0.4.3),
testthat,
Remotes:
knitr,
rmarkdown
Remotes:
hadley/rlang
RoxygenNote: 6.0.1
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
39 changes: 0 additions & 39 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,42 +61,3 @@ This example illustrates some of the advantages of purrr functions over the equi
* All `map()` functions either accept function, formulas (used for succinctly
generating anonymous functions), a character vector (used to extract
components by name), or a numeric vector (used to extract by position).

## Philosophy

The goal is not to try and simulate Haskell in R: purrr does not implement currying or destructuring binds or pattern matching. The goal is to give you similar expressiveness to an FP language, while allowing you to write code that looks and works like R.

* Instead of point free style, use the pipe, `%>%`, to write code that can be
read from left to right.

* Instead of currying, we use `...` to pass in extra arguments.

* Anonymous functions are verbose in R, so we provide two convenient shorthands.
For unary functions, `~ .x + 1` is equivalent to `function(.x) .x + 1`.
For chains of transformations functions, `. %>% f() %>% g()` is
equivalent to `function(.) . %>% f() %>% g()`.

* R is weakly typed, we need variants `map_int()`, `map_dbl()`, etc since we
don't know what `.f` will return.

* R has named arguments, so instead of providing different functions for
minor variations (e.g. `detect()` and `detectLast()`) I use a named
argument, `.right`. Type-stable functions are easy to reason about so
additional arguments will never change the type of the output.

## Related work

* [rlist](http://renkun.me/rlist/), another R package to support working
with lists. Similar goals but somewhat different philosophy.

* Functional programming librarys for javascript:
[underscore.js](http://underscorejs.org),
[lodash](https://lodash.com) and
[lazy.js](http://danieltao.com/lazy.js/).

* List operations defined in the Haskell [prelude][haskell]

* Scala's [list methods][scala].

[scala]:http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.List
[haskell]:http://hackage.haskell.org/package/base-4.7.0.1/docs/Prelude.html#g:11
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,3 @@ This example illustrates some of the advantages of purrr functions over the equi
- All purrr functions are type-stable. They always return the advertised output type (`map()` returns lists; `map_dbl()` returns double vectors), or they throw an errror.

- All `map()` functions either accept function, formulas (used for succinctly generating anonymous functions), a character vector (used to extract components by name), or a numeric vector (used to extract by position).

Philosophy
----------

The goal is not to try and simulate Haskell in R: purrr does not implement currying or destructuring binds or pattern matching. The goal is to give you similar expressiveness to an FP language, while allowing you to write code that looks and works like R.

- Instead of point free style, use the pipe, `%>%`, to write code that can be read from left to right.

- Instead of currying, we use `...` to pass in extra arguments.

- Anonymous functions are verbose in R, so we provide two convenient shorthands. For unary functions, `~ .x + 1` is equivalent to `function(.x) .x + 1`. For chains of transformations functions, `. %>% f() %>% g()` is equivalent to `function(.) . %>% f() %>% g()`.

- R is weakly typed, we need variants `map_int()`, `map_dbl()`, etc since we don't know what `.f` will return.

- R has named arguments, so instead of providing different functions for minor variations (e.g. `detect()` and `detectLast()`) I use a named argument, `.right`. Type-stable functions are easy to reason about so additional arguments will never change the type of the output.

Related work
------------

- [rlist](http://renkun.me/rlist/), another R package to support working with lists. Similar goals but somewhat different philosophy.

- Functional programming librarys for javascript: [underscore.js](http://underscorejs.org), [lodash](https://lodash.com) and [lazy.js](http://danieltao.com/lazy.js/).

- List operations defined in the Haskell [prelude](http://hackage.haskell.org/package/base-4.7.0.1/docs/Prelude.html#g:11)

- Scala's [list methods](http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.List).
114 changes: 114 additions & 0 deletions docs/articles/other-langs.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 3 additions & 24 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/accumulate.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/along.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/array-coercion.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions docs/reference/as_mapper.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/as_vector.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/compose.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/cross.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/depth.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/detect.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/every.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 011e690

Please sign in to comment.