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.

handling of duplicate keys in Object$prototype$concat

See original GitHub issue

Sanctuary:

> Z.concat({x: 1, y: 1}, {y: 2, z: 2})
{x: 1, y: 2, z: 2}

Haskell:

> M.fromList [('x', 1), ('y', 1)] <> M.fromList [('y', 2), ('z', 2)]
fromList [('x', 1), ('y', 1), ('z', 2)]

We didn’t discuss this behaviour in #2 as far as I can see; I think we diverged from Haskell’s behaviour unintentionally.

/cc @puffnfresh

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
davidchamberscommented, Apr 29, 2017

Let’s stick with the current behaviour for the time being. As it’s not clear that one approach is better than the other it’s best to leave things as they are. We can revisit this issue if new information comes to light.

1reaction
safarelicommented, Apr 22, 2017

In haskell mappend of Map is “left-biased” in JS we have similar function Object.assign (R.merge has similar semantics) which are right biased, so I think is better to stick with what we have as it’s more intuitive to JS developer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Merge duplicate keys in simple object [closed] - Stack Overflow
A javascript object cannot have duplicated keys, so this will not work. If instead you had an array of objects containing one or...
Read more >
Removing duplicates in an Array of Objects in JS with Sets
My first instinct was to make a new array, and loop through the addresses' array and do a . findIndex on each for...
Read more >
Object.assign() - JavaScript - MDN Web Docs
The Object.assign() static method copies all enumerable own properties from one or more source objects to a target object.
Read more >
How to copy objects in JavaScript: A complete guide
A complete guide to copying objects in JavaScript: shallow copy, deep copy, assigning, merging, and structured cloning.
Read more >
javascript find duplicate values in object - You.com
In JavaScript, an object consists of key-value pairs where keys are similar to indexes in an array and are unique. If one tries...
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