title: Compose Ramda Functions
body: <p>Hi am just learning the <code>Ramda</code> library and loving it. I am trying to practice some functional concepts like <code>curry</code> and <code>immutability</code>.  Below I have a little code that is basically trying to <code>assoc</code> the value from one <code>object</code> and copy that to another <code>object</code>.  The first <code>object</code> <code>kdlJsonObj</code> has the <code>cost</code> value, that I would like to append that to another object </p>
  
  <pre><code>//object from API
  var kdlJsonObj = [
    {name: 'AAA COOPER TRANSPORTATION', cost: 33},
    {name: 'OLD DOMINION FREIGHT LINE, INC', cost: 22},
    {name: 'ROADRUNNER  TRANSPORTATION SERVICES', cost: 31}
  ]
  
  // objects to assoc 
  var aaa = {shortName: 'AAA Cooper', name: 'AAA COOPER  TRANSPORTATION' }
  var odlf = {shortName: 'Old Dominion', name: 'OLD DOMINION FREIGHT LINE, INC'}
  var rr = {shortName: 'Road Runner', name: 'ROADRUNNER  TRANSPORTATION SERVICES'}
  
  // Ramda functions that I would like to compose    
  var namePropEq = R.propEq('name')
  var namePropEqAAA = namePropEq('AAA COOPER TRANSPORTATION')
  var findAAA = R.find(namePropEqAAA, kdlJsonObj) 
  var costProp = R.prop('cost')
  var costAAA = costProp(findAAA)
  var assocCost = R.assoc('cost')
  var assocCostAAA = assocCost(costAAA)(aaa)
  assocCostAAA // =&gt; {shortName: "AAA Cooper", name: "AAA COOPER TRANSPORTATION", cost: 33}
  </code></pre>
  
  <p>I would like to be able to compose these set of function make it a more point-free style of coding where no data is provided until I make the call.  Ideally it would be something like <code>var assocCostAAA = composeAssoc(namePropEqAAA)(aaa)</code> and I could just call one function. I am not sure it is possible to <code>compose</code> this function because of the arity rules</p>
  
  <pre><code>var composeAssoc = R.compose(
     R.assoc('cost'),
     R.find(name, kdlJsonObj),   // has two arity so i believe this is not correct
     R.propEq(name))
  </code></pre>
  
  <p>I am open to doing it different ways.  Such as using <code>Ramda</code> functions like <code>R.pluck</code>,<code>R.filter</code> maybe even <code>R.lens</code>. But I would love for it to be a composed/declarative function.</p>