These are chat archives for ramda/ramda

28th
May 2016
andretshurotshka
@goodmind
May 28 2016 09:22
@Bradcomp but how compose 2-arity func with 2-arity func? R.compose seems only works with unary functions
andretshurotshka
@goodmind
May 28 2016 09:41
This message was deleted
ram-bot
@ram-bot
May 28 2016 09:41
Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
andretshurotshka
@goodmind
May 28 2016 09:43
@ram-bot
var transformations = {
  chat_id: R.defaultTo(1),
  text: R.defaultTo('hi')
}

var obj = {
  chat_id: 2,
}

var keys = R.chain(R.keys, [transformations, obj])

R.evolve(transformations, R.pickAll(keys, obj))
ram-bot
@ram-bot
May 28 2016 09:43
{ chat_id: 2, text: 'hi' }
andretshurotshka
@goodmind
May 28 2016 09:45
@Bradcomp I don't see how to compose here
Rafe
@rjmk
May 28 2016 13:08
@goodmind In ramda you can actually
@ram-bot
var transformations = {
  chat_id: R.defaultTo(1),
  text: R.defaultTo('hi')
}

var obj = {
  chat_id: 2,
}

var keys = R.chain(R.keys, [transformations, obj])

R.compose(R.evolve(transformations), R.pickAll)(keys,obj)
ram-bot
@ram-bot
May 28 2016 13:09
{ chat_id: 2, text: 'hi' }
Rafe
@rjmk
May 28 2016 13:09
Because of some trickery with compose. With a simpler compose (for example Sanctuary's B) you can do the following
@ram-bot
var transformations = {
  chat_id: R.defaultTo(1),
  text: R.defaultTo('hi')
}

var obj = {
  chat_id: 2,
}

var keys = R.chain(R.keys, [transformations, obj])

S.B(S.B(R.evolve(transformations)), R.pickAll)(keys)(obj)
ram-bot
@ram-bot
May 28 2016 13:10
{ chat_id: 2, text: 'hi' }
Hardy Jones
@joneshf
May 28 2016 15:45
@ChetHarrison pong
@rjmk Great example with typed compose! Though I wonder if you could do it with something simpler, like GADT's?
Hardy Jones
@joneshf
May 28 2016 16:15
Brad Compton (he/him)
@Bradcomp
May 28 2016 18:13
@goodmind :point_up: What @rjmk said. Alternately, if you are just defaulting some values if the keys don't exist, you could just use merge, or do something with mergeWith if you want to get more tricky with handling null values.
@ram-bot
var defaults = {
  chat_id: 1,
  text: 'hi'
}

var obj = {
  chat_id: 2
}

const defaultKeys = merge(defaults);

defaultKeys(obj)
ram-bot
@ram-bot
May 28 2016 18:13
{ chat_id: 2, text: 'hi' }
LeonineKing1199
@LeonineKing1199
May 28 2016 22:13
@CrossEye Hey, I'm glad to hear that! I might try to whip up a formal implementation this weekend. I'm also kind of trying to get back into CUDA stuff but Nvidia's IDE doesn't support installing plugins right now so if I get sick of dealing with that, I might be more inclined to create the currying function.
LeonineKing1199
@LeonineKing1199
May 28 2016 22:20
One thing about variadic currying is, I'm going to sort of treat variadics how C++ treats it with its expansion of parameter packs. E.g., all declared and named variables will be on the left and the variadic arguments start on the right. Normally the C++ compiler will complain about the templated ambiguities and I agree with that design choice so that's how I'm going to design the currying function.
andretshurotshka
@goodmind
May 28 2016 22:27
This message was deleted
This message was deleted
This message was deleted