ramda: Why don't we have the Haskell's groupBy function?

Use case

I have an array of objects. Each object contains a parsed street address like this one:

{
   country: 'Russia',
   house_number: '5/6',
   road: "Tverskaya Street",
   ...
   theatre: "Театр им. М.Н. Ермоловой"
}

The problem is that some addresses are too specific. For example I don’t need to know about the theatre that is located there. From this point of view my array contains duplicates (theatre, bakery, hotel and others that are located in the same building). And I need to replace this duplicates with one, least specific address, with the same house number but without unwanted information about theatre and others. There is always one such address for all the duplicates.

In Haskell we have a wonderful groupBy function that can help me locate a sequence of duplicates and reduce them to one address by a predicate. But Ramda’s groupBy returns an object so I lose the original order. But order is important because addresses were sorted by relevance.

I am sorry for my english and possibly excessive verbosity.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (16 by maintainers)

Most upvoted comments

The problem with groupBy/groupWith is that they would return values of different types. I believe our other *By/*With pairs differ only in terms of their input types.

cluster?