title: Capturing object's "safe state" within pipe chain
body: <p>I'm running some scientific experiments which involve quite a lot of trial and error. What I basically do is pass some object along a chain of numerical methods with a bunch of parameters on each stage like so:</p>
  
  <pre><code>x &lt;- define_object(param1, param2) %&gt;%
       run_method(param3, param4) %&gt;%
       process_results(param5) %&gt;%
       save_plot(param6)
  </code></pre>
  
  <p>When everything goes smooth, I'm happy. However, each stage may fail (e.g. I modified the source and left a syntax error or the method is not compatible with the parameter set I provide), so the whole chain stops and the object is lost regardless of the steps that succeeded. In such cases I'd like to keep the object in its' latest valid state (I call that a "safe state"). I need that because each stage can take quite some time to execute.</p>
  
  <p>Well, naturally, the trivial answer would be to ditch the piping paradigm and go with traditional approach:</p>
  
  <pre><code>x &lt;- define_object(param1, param2)
  x &lt;- run_method(x, param3, param4)
  x &lt;- process_results(x, param5)
  x &lt;- save_plot(x, param6)
  </code></pre>
  
  <p>so I can resume the chain as soon as I fix it. </p>
  
  <p>But maybe there's an option to still have pipes and keep the safe state? I'm not a number one fan of pipes, but the flow I have for this task asks for it, though the inconvenience I described is a deal-breaker. </p>