These are chat archives for ramda/ramda

28th
Jan 2019
Shea Parkes
@shea-parkes
Jan 28 02:42

Thanks everyone for the very nice library. The cookbook has helpful examples, but I'm still struggling to see the right way to do some simple things. For example, this really doesn't feel idiomatic:

const lookupTable = {'bob': 10, 'alice': 12, 'eve': 13}
const transaction = {name: 'bob', due: 22}

const curriedLookup = R.converge(
  R.call,
  [
    R.always(R.prop),
    R.pipe(R.nthArg(1), R.prop('name')),
    R.nthArg(0),
  ]
)

curriedLookup(lookupTable)(transaction)

Is there a better way to build a function that accepts a lookup table first and then a record to lookup second? Is the idiomatic answer "just mixin an arrow function"? Thanks again.

matrixbot
@matrixbot
Jan 28 06:23
kapil1 ```
kapil1 accountIdField.set('value', row.accountId) lastRowPayment.$('amount').set('value', row.amount) lastRowPayment.$('transDate').set('value', row.transDate) lastRowPayment.$('source').set('value', row.source) lastRowPayment.$('memo').set('value', row.memo)
kapil1 how to reduce above functions with one line in ramda?
Johnny Hauser
@m59peacemaker
Jan 28 16:30
Is anyone using eslint with this style currying?
foo
  (etc)
  (etc)
I can't find a config to make that work with indentation
Lewis
@6ewis
Jan 28 18:03
yo
i wanna use R.evolve with new data
example:
conversation: {
       id: 0,
       messages: friends[0].messages,
   }

const transformations = {
      id: R.identity(position), ///position is coming from outside
      messages: R.identity(friends[position].messages)
    } 

const newSchtuff =      R.evolve(
        transformations,
        conversation
      )
Riku Tiira
@rikutiira
Jan 28 18:07
@6ewis R.evolve expects functions but R.identity(val) returns the value, you probably want to use R.always here
Lewis
@6ewis
Jan 28 18:08
thanks @rikutiira
i cant never read the signature {k: (v → v)} → {k: v} → {k: v} ==> everytime i figure that out i forget 3 months later
first one is i expect a function, then...what?
Riku Tiira
@rikutiira
Jan 28 18:14
{k: (v → v)} part tells you that you take an object with key/value transformers, then second argument is an object of key/value pairs and it returns a new object of key/value pairs
and if the type signatures are giving you trouble, the expanded paramters and/or documented functionality are usually more helpful anyway