Skip to content
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

Can't we drastically reduce the amount of purrr variants, AND expand possibilities, by using adverbs ? #8

Closed
moodymudskipper opened this issue Apr 29, 2019 · 1 comment

Comments

@moodymudskipper
Copy link
Owner

We would be less efficient but can't we create any purrr::map* function from lapply by using adverbs/tags/adverb factories for :

  • use of formula lambdas : map etc
  • type stability : map_dbl, map_chr , modify etc
  • using index or name : imap etc
  • l* variants : lmap etc
  • *_at / *_if variants : map_if, map_at etc
  • _depth variants : map_depth, modify_depth
  • special variants : map_if_else (upcoming), map_case_when (requested)
  • map2 variants : map2; map2_chr etc
  • pmap variants : pmap, pmap_chr etc

The way purrr seems to work now is that variants are created for each of those, AND if a combination is deemed common enough it gets its own verb. Inevitably we sometimes want a combination that doesn't exist, but they can't all exist.

The goal is not to replace the existing variants, but by extracting these features into independant adverbs (tags, adverb factories...) we can :

  • fill the gaps in purrr
  • Use these features on functions from other packages

Type stability adverbs are really simple to implement as it's just post processing.

We already implemented the lambda formula adverb as a simple preprocessing on function arguments using heuristics (but using adverb factories we could be more flexible and name the argument to preprocess).

Adverbs for other variants might be more complex and less easy to generalize to a wide range of input functions but it's worth taking a shot.

This family of adverbs might be a nice use case for dialects , we could throw in an adverb for progress bars, and quasi quotation too.

@moodymudskipper moodymudskipper pinned this issue Apr 29, 2019
@moodymudskipper moodymudskipper unpinned this issue Apr 29, 2019
@moodymudskipper moodymudskipper transferred this issue from moodymudskipper/tag Apr 30, 2019
@moodymudskipper
Copy link
Owner Author

to the fridge for now, the most useful variants would be to build the functionalities of the i prefix and _at _if suffixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant