These are chat archives for ramda/ramda

12th
Mar 2015
John-David Dalton
@jdalton
Mar 12 2015 00:11
Sure I can open issues if you like.
You interested in the string ones too or just object issues?
Scott Sauyet
@CrossEye
Mar 12 2015 00:41
@jdalton: I was under the impression you were discussing bugs. I'd definitely want issues opened for those. I was hoping that SauceLabs would be enough to keep us close on old IE. If it's points of API design you're taking about, feel free to raise them if you like, but I feel much less urgency.
But Object/String whatever
You feel like.
John-David Dalton
@jdalton
Mar 12 2015 01:11
It's bugs you don't have test coverage for.
Scott Sauyet
@CrossEye
Mar 12 2015 02:55
Then definitely would love issues.
Sergey Lapin
@lapanoid
Mar 12 2015 13:29
Is 0.11.0 unstable? I see failing tests https://travis-ci.org/ramda/ramda/builds
Xavier Ho
@Spaxe
Mar 12 2015 13:29
That's the master branch, not 0.11.0.
Sergey Lapin
@lapanoid
Mar 12 2015 13:30
Ok thanks
@Spaxe if some package in npm is failed it would be red npm badge? Just for future
Xavier Ho
@Spaxe
Mar 12 2015 13:31
Sorry, I don't know the answer to that one.
Raine Virta
@raine
Mar 12 2015 13:35
red npm badge?
i doubt this will ever be red https://badge.fury.io/js/ramda.svg
Sergey Lapin
@lapanoid
Mar 12 2015 13:37
It is silly to publish something unstable but shit happens, how can I be sure that version from npm pass all tests?
Raine Virta
@raine
Mar 12 2015 13:37
it wouldn't be there if it didn't pass tests
Sergey Lapin
@lapanoid
Mar 12 2015 13:38
ok, fair enough
David Chambers
@davidchambers
Mar 12 2015 15:32
$ grunt sauce
Running "connect:server" (connect) task
Started connect web server on http://localhost:3210
Running "saucelabs-mocha:all" (saucelabs-mocha) task
=> Starting Tunnel to Sauce Labs
=> Stopping Tunnel to Sauce Labs
>> 
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated
The tests are passing, it's just that Sauce Labs and/or our sauce tests are flaky and sometimes time out.
Nate Wildermuth
@wildermuthn
Mar 12 2015 22:11
          _.each(videoIds, function(id) {
            _.each(items, function(item) {
              if (id === item.id) {
                metrics.push(item.metrics);
              }
            });
          });
For the life of me, I can't figure out how to turn this into readable code with Ramda.
          var getMetrics = R.map(R.prop('metrics'));
          var filterById = id => R.filter(R.propEq('id', id));
          var getItemMetrics = id => R.pipe(
            filterById(id),
            getMetrics,
            R.head
          );
          var matchFns = R.map(getItemMetrics, videoIds);
          var matches = R.map(fn => fn(items), matchFns);
Nate Wildermuth
@wildermuthn
Mar 12 2015 22:18
It's such a simple problem when thinking about it imperatively. But I struggle to figure out how to approach it functionally.
Nate Wildermuth
@wildermuthn
Mar 12 2015 22:23
          var matches = R.map(R.prop('metrics'), R.filter(item => R.contains(R.prop('id', item), videoIds), items));
Hardy Jones
@joneshf
Mar 12 2015 22:38
what do you consider readable?
Hardy Jones
@joneshf
Mar 12 2015 22:53
But it looks like you're doing things a bit differently when you convert between the two.
can you provide a bit more informaion on what types you're dealing with here/
Hardy Jones
@joneshf
Mar 12 2015 23:00
@TheLudd late to the party, but what about R.flip(R.call) http://ramdajs.com/repl/?v=0.11.0#var%20apply%20%3D%20R.flip(R.call)%3B%0A%0Aapply(3%2C%20R.add(10))%3B seems to do the trick.
Eero Saynatkari
@rue
Mar 12 2015 23:05
@wildermuthn That’s the way I’d go. You need the subset of items that have a corresponding video id entry, and then just iterate over those
erm...
This message was deleted
This message was deleted
var videoIds = [1,2,3,4];
var items = [
  {id: 2, name: 'foo'},
  {id: 3, name: 'bar'},
  {id: 5, name: 'baz'}
];

var out = R.chain(function(id) {
  return R.filter(R.propEq('id', id), items);
}, videoIds);

JSON.stringify(out, null, 4)
Hardy Jones
@joneshf
Mar 12 2015 23:13
You could write it point-free also, if that's what you're after:
R.chain(R.pipe(R.propEq('id'), R.filter(R.__, items2)))(videoIds)
semi-pointfree I guess with R.__ ;)
Or split it out if that makes more sense:
var filterById = R.pipe(R.propEq('id'), R.filter);
var out = R.chain(filterById(items), videoIds);
Hardy Jones
@joneshf
Mar 12 2015 23:19
The intuition for chain is that the inner each/map/filter/whatever, depends on the outer value, so monadic should be popping out at you.
anytime you have some algorithm where the value you're currently computing depends on the choice of a previous value, it's monadic.