title: Change Value Properties in Object with Ramda Lenses
body: <p>I would like to know how can I change object properties with Ramda Lenses.</p>
  
  <p>Currently, I have a deep state :</p>
  
  <pre><code>buckets[
      blocks[
          messages[
              replies [
                  {id: 0, text: 'text 0', value: 'simple value 0'},
                  {id: 1, text: 'text 1', value: 'simple value 1'},
                  {id: 2, text: 'text 2', value: 'simple value 2'},
                  ...
              ]
          ]
      ]
  ]
  </code></pre>
  
  <p>I have a basic payload. I would like to get the property and the value, and set the old value by the new value in my state, for example with this payload :</p>
  
  <blockquote>
    <p>{text: 'new_text'}
    or
    {value: 'new_value'}</p>
  </blockquote>
  
  <p>In my reducer I have this :</p>
  
  <pre class="lang-js prettyprint-override"><code>case SEQUENCES.UPDATE_REPLY_ON_BLOCK :
  // payload =&gt; {text: 'new_text'}, or {value: 'new_value'}, or anyway...
  
  let key = Object.keys(payload)[0];
  let value = payload[key];
  
  return R.over(
    R.lensPath(["buckets", 0, "blocks", 0, "messages", 0, "replies", 0, key]),
    R.set(value),
    state
  );
  </code></pre>
  
  <p>I tried with Merge :</p>
  
  <pre><code>return R.over(
      R.lensPath(["buckets", 0, "blocks", 0, "messages", 0, "replies", 0),
      R.merge(payload),
      state,
  );
  </code></pre>
  
  <p>But same result : the state is not modified and I have no error.</p>
  
  <blockquote>
    <p>Maybe SOLVED with mergeDeepLeft :</p>
  </blockquote>
  
  <pre><code>//payload =&gt; {value: 'new_value'}
  
  return R.over(
      R.lensPath(["buckets", 0, "blocks", 0, "messages", 0, "replies", 0),
      R.mergeDeepLeft(payload),
      state,
  );
  </code></pre>