// https://github.com/ramda/ramda/wiki/Cookbook#diffobjs---diffing-objects-similar-to-guavas-mapsdifference
const groupObjBy = R.curry(R.pipe(
  // Call groupBy with the object as pairs, passing only the value to the key function
  R.useWith(R.groupBy, [R.useWith(R.__, [R.last]), R.toPairs]),
  R.map(R.fromPairs)
))

const objectDiff = R.pipe(
  R.useWith(R.mergeWith(R.merge), [R.map(R.objOf('leftValue')), R.map(R.objOf('rightValue'))]),
  groupObjBy(R.cond([
    [
      R.both(R.has('leftValue'), R.has('rightValue')),
      R.pipe(R.values, R.ifElse(R.apply(R.equals), R.always('common'), R.always('difference')))
    ],
    [R.has('leftValue'), R.always('onlyOnLeft')],
    [R.has('rightValue'), R.always('onlyOnRight')]
  ])),
  R.evolve({
    common: R.map(R.prop('leftValue')),
    onlyOnLeft: R.map(R.prop('leftValue')),
    onlyOnRight: R.map(R.prop('rightValue'))
  })
)