question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pluck :: Accessible a => TypeRep b -> String -> Array a -> Array (Maybe b)

See original GitHub issue

In 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 for map + gets;
  • we provide a shorthand for map + get but not for map + 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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
davidchamberscommented, Nov 21, 2016

I do think map + prop is a more common combination than map + get, so I am open to the idea of changing pluck rather than removing it.

1reaction
svozzacommented, Nov 22, 2016

I like the idea of changing to map + prop. I can do the PR if that’s how we decide to go.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found