pluck :: Accessible a => TypeRep b -> String -> Array a -> Array (Maybe b)
See original GitHub issueIn its infancy Sanctuary was a companion to Ramda, focused on providing safe versions of unsafe Ramda functions. Sanctuary is now close to being a Ramda alternative, and provides many more functions than it once did. It’s important to occasionally remove poorly defined and/or unnecessary functions so the library becomes more coherent over time, even as it grows.
pluck
provides a slightly more succinct way to express a composition of map
and get
:
> S.pluck(Number, 'x', [{x: 1}, {x: 2}, {x: '3'}, {x: null}, {}])
[Just(1), Just(2), Nothing(), Nothing(), Nothing()]
> R.map(S.get(Number, 'x'), [{x: 1}, {x: 2}, {x: '3'}, {x: null}, {}])
[Just(1), Just(2), Nothing(), Nothing(), Nothing()]
I have several issues with pluck
:
- it doesn’t provide much of a readability improvement over
map
+get
; - we provide a shorthand for
map
+get
but not formap
+gets
; - we provide a shorthand for
map
+get
but not formap
+prop
; and - type representatives are a complex concept best referenced in as few places as possible.
If you’re okay with pluck
being removed from the library, vote 👎; if you would like the function to stay, vote 👍. If in addition to keeping pluck
you think we should add plucks
as shorthand for map
+ gets
, please say so. Thanks. 😃
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top Results From Across the Web
v0.12.0 release notes · Issue #332 · sanctuary-js ... - GitHub
Sanctuary functions now have useful string representations for those ... props :: Accessible a => Array String -> a -> b ( Add...
Read more >DataWeave pluck function: How to transform an Object into an ...
In this tutorial, you will learn how to transform an input Object into an Array with the pluck function. pluck is similar to...
Read more >Array - JavaScript - MDN Web Docs
Primitive types such as strings, numbers and booleans (not String , Number , and Boolean objects): their values are copied into the new...
Read more >How do I remove blank elements from an array?
There are many ways to do this, one is reject noEmptyCities = cities.reject { |c| c.empty? } You can also use reject! ,...
Read more >What I Wish I Knew When Learning Haskell 2.3 ( Stephen Diehl )
λ: :info Functor class Functor f where fmap :: (a -> b) -> f a -> f b (<$) :: a ... Array...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I do think
map
+prop
is a more common combination thanmap
+get
, so I am open to the idea of changingpluck
rather than removing it.I like the idea of changing to
map
+prop
. I can do the PR if that’s how we decide to go.