These are chat archives for ramda/ramda

May 2018
Stephen Niemans
May 13 2018 01:08
@klequis I'm sure there are many ways of doing it, but here's another :)
const getNewState = (state, {_id, field, value}) => {
  const isMatch     = R.propEq('_id', _id)
  const updateValue = R.assoc(field, value)
  const updatePhone = => isMatch(p) ? updateValue(p) : p)
  return R.assoc('phone', updatePhone(, state)

console.log(getNewState(state, payload))
Vesa Karvonen
May 13 2018 07:56

@klequis With Partial Lenses you could do something like this:

const update = ({field, value, _id}, state) =>
  L.set(['phone', L.find(R.whereEq({_id})), field], value, state)

Here is the example in a playground.

May 13 2018 21:45
@polytypic That is much cleaner. Thank you!
@stephenniemans Like your solution as well - Thank you!
Stephen Niemans
May 13 2018 21:47
you're welcome, I tried to keep it a bit close to your original approach but with some of the Ramda functions thrown in :)
That partial lenses library looks insanely powerful
But also like it will take some work to grasp for me
May 13 2018 21:50
Yes, when I first skimmed the Partial Lenses readme it seemed beyond reach and making wider use of it looks like an investment, but I do think I get Vesa's example. Not going to use until I have time to think/learn about it though.
Stephen Niemans
May 13 2018 21:52
If manipulating deeply nested objects ever becomes a commonly recurring part of my tasks I will invest in it most likely but for now I have a lot of other things to learn haha
I think for basic use of lenses the ones that come with Ramda should hopefully help me along enough
May 13 2018 21:59
someone here knows Standard ML for a few questions?