These are chat archives for ramda/ramda

21st
May 2015
Scott Sauyet
@CrossEye
May 21 2015 02:02
Have to ask @davidchambers about that. There was lot going on related to where, but I don't recall any actual discussion about that issue.
Scott Sauyet
@CrossEye
May 21 2015 02:11
@paldepind: Yes, a wrote a brief comment on our signatures: https://github.com/ramda/ramda/issues/1035#issuecomment-95327214
Asaf
@asaf-romano
May 21 2015 05:00
@CrossEye should I open a ticket?
btw, is this a bug or a misunderstanding http://bit.ly/1Bdkpls
Kevin Wallace
@kedashoe
May 21 2015 05:36
@asaf-romano interesting. what is your use case? you can make that work like this: http://bit.ly/1K3MEZ5
because useWith is variadic, it cannot easily be general purpose curried
(it actually is curried, but I believe that is simply for completeness sake?)
which basically just does curryN(1, function useWith...
Asaf
@asaf-romano
May 21 2015 06:37
@kedashoe I have a config-like system, in which all functions have the same signature, and I want to "wrap" arguments in Date objects
basically a list of (startTime, endTime) functions, that I want to make sure that are called with dates.
anyway, when it comes to something like curryN, I prefer to write an explicit function, something like function fixIt(func) { return userWith(func, ...) }
thanks for explaining the underlying issue.
David Chambers
@davidchambers
May 21 2015 07:11
The thing it takes for granted is an understanding of curried functions.
David Chambers
@davidchambers
May 21 2015 07:17
@asaf-romano: R.where’s special handling of null/undefined was removed in #1036, intentionally. You can use Object(x) to coerce x to {} if x is null/undefined. I don’t think Ramda should do this automatically.
Raine Virta
@raine
May 21 2015 07:21
good to know that Object(x) trick
Asaf
@asaf-romano
May 21 2015 08:48
@davidchambers thanks, it just gets very verbose when you don't (or cannot) use compose :(
I recognize the rational though.
filter(where(...), map(Object, pluck("somethingOptional", theList)))
Scott Sauyet
@CrossEye
May 21 2015 14:55
@asaf-romano Feel free to open an issue of you like. We've been removing the variadic functions from Ramda, and maybe useWith should take an array of transformer functions.
Jethro Larson
@jethrolarson
May 21 2015 16:01
Will you leave compose and pipe like they are, or create pipeAll for arrays of fns?
Btw https://twitter.com/jashkenas/status/601410963695345664 kind of exciting. I'm not convinced it'll happen, but it's overdue
Raine Virta
@raine
May 21 2015 16:17
pipeAll = apply(pipe)
Michael Hurley
@buzzdecafe
May 21 2015 16:41
nice @raine

Will you leave compose and pipe like they are, or create pipeAll for arrays of fns?

i'm curious to experiment with making compose a binary curried function. but for that to be useful, would have to guarantee you get a curried function out of compose. which we should be doing anyways, but that's another discussion ...

Hardy Jones
@joneshf
May 21 2015 16:52
That'd be great if compose/pipe were made binary.
Michael Hurley
@buzzdecafe
May 21 2015 16:56

btw, is this a bug or a misunderstanding http://bit.ly/1Bdkpls

@asaf-romano that looks like a bug to me. certainly surprising. please file an issue. i like the placeholder less and less every day

Shane Keulen
@SeeThruHead
May 21 2015 19:25
does ramda have a way to map an array to an object with keys = values of the array, and values equal to the result of a function call with the array values, trying to think of a functional way to do this an i'm falling short
Michael Hurley
@buzzdecafe
May 21 2015 19:32
reduce?
or map(assoc)
Raine Virta
@raine
May 21 2015 19:32
var fn = function(f, arr) {
  return zipObj(arr, map(f, arr))
};

fn(toUpper, [ 'foo', 'bar', 'xyz' ])
// { foo: 'FOO', bar: 'BAR', xyz: 'XYZ' }
is that the right output?
Shane Keulen
@SeeThruHead
May 21 2015 19:33
@buzzdecafe oh, seems so obvious now
Raine Virta
@raine
May 21 2015 19:33
btw gitter gist integration is sometimes overkill
Michael Hurley
@buzzdecafe
May 21 2015 19:33
i like @raine 's
Shane Keulen
@SeeThruHead
May 21 2015 19:34
oh yes, that's perfect
Shane Keulen
@SeeThruHead
May 21 2015 19:50
sorry i'm pretty new to fp and this is my first time giving ramda a go, how would I check property names of an object and makes some changes to that property and then return the altered object with ramda
Raine Virta
@raine
May 21 2015 19:51
either mapObjIndexed or evolve might be ok
Hardy Jones
@joneshf
May 21 2015 19:53
@SeeThruHead i think the best way to learn is to break the functionality you want to do into simple functions around 2-3 lines or so that implement each piece, and then join them together with the appropriate functions.
you might end up with a bunch of functions, but that's part of the point. When it starts to become more natural, you'll see similarities and shortcuts and whatever.
For example, in your first request you can see a few simple operations there:
  1. take each value and create an object where the key is the value and the value is the result of a function
  2. take an array of those things and make each one an object
  3. combine them somehow into an object.
Hardy Jones
@joneshf
May 21 2015 20:02
  1. assuming some function f:
    var objectify = function(x) {
      return {x: f(x)};
    };
  2. This is R.map.
  3. You can use reduce here.
    var combine = function(xs) {
      return R.reduce(R.merge, {}, R.map(objectify, xs));
    };
It's not as clean as @raine 's solution, but it works.
or should work ;)
Hardy Jones
@joneshf
May 21 2015 20:07
And you can decompose it in many different ways.
Another option involves using R.fromPairs.
Tobias Pflug
@gilligan
May 21 2015 20:10
found this useful for working with fantasy-land Either : https://gist.github.com/gilligan/cda8d69f8cad5bd9643f
.oO(the type signature of either is a bit of a lie of course ...)
Hardy Jones
@joneshf
May 21 2015 20:39
wait, how does that work?
i mean, how does it do anything sensible?
oh, I get it
well that relies on unspecified behavior
Shane Keulen
@SeeThruHead
May 21 2015 20:51
how does this work var optikPlans = R.mapObj(R.pick(optikPlanProvs), R.merge(optik));
this is harder to get my head around than i expected
Raine Virta
@raine
May 21 2015 21:00
try breaking it up in pieces. less data, more functions
and i don't think that works, mapObj takes an object as second argument, R.merge(optik) returns a function
Shane Keulen
@SeeThruHead
May 21 2015 21:34
is there a deep-merge? i've been trying to merge json files with { "prop" [{}, {}] } but the things i need to merge are the objects inside that array
Raine Virta
@raine
May 21 2015 21:35
not yet I think, ramda/ramda#1088
Michael Hurley
@buzzdecafe
May 21 2015 22:37
beware deep merge .... there be dragons