These are chat archives for ramda/ramda

31st
Jul 2017
Michael Rosata
@mrosata
Jul 31 2017 00:06
@JasonShin I can't really think of a reason not to except that the project is no longer supported I heard. A lot of people like Fluture better for Futures (myself included). Sanctuary is great for the Maybe and Either, but it could be easier to get people at your work using Ramda-Fantasy. I think if you have a good grasp on Ramda-Fantasy then that would probably be the way to go. If you just need the Future then maybe just introducing that to them at first is a safer bet. It really depends on how comfortable you are with the technology that you are bringing into the project since people would likely look to you for solutions when they hit the road-bumps we all hit learning this stuff
Jason Shin
@JasonShin
Jul 31 2017 00:50
right ok, cool thanks
I will have a look at Fluture too, I had a look at it last time and played around with it too
it looks good
Rafi
@Rafi993
Jul 31 2017 01:19
Hi I have been trying to achieve this https://goo.gl/iBj6Vq but I could not proceed further any help would be really appreciated
const data = [{
      "_index": "search_index",
      "_type": "search_type",
      "_id": "Co5EFxnqeo9ruq",
      "_score": 1,
      "_source": {
        "admin_tags": [],
        "type": "human",
        "folder": "Feature Samples",
        "url_t": "url_tdata",
        "users": [
          128
        ],
        "agent_id": 2,
        "url": "url_data",
        "favorited_by": [20],
        "idx": 121,
        "path": "Report Samples//Feature Samples",
        "name": "Grouping and Sorting",
        "description": ""
      }
}];

const mapIndexed = R.addIndex(R.map);

const tg = mapIndexed((x,i)=>({
    "name": x._source.admin_tags[0]==undefined?"Unclasified":x._source.admin_tags[0],
     "idx": i,
    "folder":[{
     "name": x._source.folder,
     "idx": x._source.folder,
     "report":[{
     "agent_id": x._source.agent_id,
     "description": x._source.description,
     "favorited_by": x._source.favorited_by[0],
     "name": x._source.name,
     "idx": x._source.idx,
     "path": x._source.path, 
     "type": x._source.type,
     "url": x._source.url,
     "url_t": x._source.url_t,
     }]
    }]
  }),data);

const byTag = groupBy(data=> data.name)
const tagged = byTag(tg);
tagged

const output = {
  "message": "",
  "payload": [{
    "name":"Unclasified",
    "idx":0,
    "folders": [{
        "idx": "Feature Samples",
        "name": "Feature Samples",
        "reports": [{
          "agent_id": 2,
          "description": "",
          "idx": 121,
          "is_fav": 20,
          "name": "Grouping and Sorting",
          "type": "human",
          "url": "url_data",
          "url_t": "url_tdata",
          "user_report_id": 0, 
          "views": 0, 
          "report_id": '2sdfsd' 

        }]
    }]
  }]
}
Rafi
@Rafi993
Jul 31 2017 01:37
Here I have initialized the sub arrays folder and report but they are not grouped. since there can be multiple folders and reports.
Rafi
@Rafi993
Jul 31 2017 05:55
and I am trying to do this in point free form
Selwyn
@Siilwyn
Jul 31 2017 19:24
:wave: folks trying to take out all changed objects from two objects: basically merge them in a way and get the changes in an array. Think R.differenceWith comes into play but I've been stuck at this problem for hours now. Can't think of how to transform the objects so that they can be mapped while retaining the property info. Made a simplified REPL: https://goo.gl/oRcG1z
Philipp Wille
@Yord
Jul 31 2017 19:54
@Siilwyn :wave: This is how far I got:
const sampleA = { a: {s: false}, b: {s: true} };
const sampleB = { a: {s: true}, b: {s: true} };

const out = { a: [ {s: false}, {s: true} ] };

const getDifferences = pipe(
  symmetricDifferenceWith(equals),
  groupBy(head),
  map(chain(tail))
)

const result = getDifferences(toPairs(sampleA), toPairs(sampleB))

equals(result, out) // true
It's too late for me to keep trying ;) Your intuition with differenceWith was just about right
I bet there is still a lot to improve
Philipp Wille
@Yord
Jul 31 2017 20:08
(If you wanted to get rid of the toPairs in the parameters, you could do the following, which is unfortunately not very clear in my opinion)
const getDifferences = pipe(
  (...args) => map(toPairs, args),
  apply(symmetricDifferenceWith(equals)),
  groupBy(head),
  map(chain(tail))
)

getDifferences(sampleA, sampleB)
Brad Compton (he/him)
@Bradcomp
Jul 31 2017 20:09
This may provide some inspiration
Selwyn
@Siilwyn
Jul 31 2017 20:13
Thank you so much @Yord!
<3 going to work from your snippets
Thank you too @Bradcomp will try to understand that example, I already glossed over it. ^^