These are chat archives for ramda/ramda

28th
Jun 2018
Stefano Vozza
@svozza
Jun 28 2018 11:58
ramda and streams go very well together, one of the most common operations you do with streams is map which for me were often just applying Ramda compositions
Shawn Talbert
@ShawnTalbert
Jun 28 2018 13:55
doesn't seem to work for me. My situation is basically this: I have a 'database-like' api that I query that returns an arbitrarily large result set. Using an iterator-like approach I can abstract all the machinery to page through results. I want my end-user code to simply map over results without concern for how many results may actually arrive.
so I have an arbitrary length collection whos values needs to be pulled one page at a time that I'm trying to look like a seamless stream of results for use in ramda or similar. At the moment Immutable Seq fit well as it accepts an iterator directly and allows me to do lazy eval for map and friends
David Jegat
@Djeg
Jun 28 2018 14:10
Hello guys. First thanks for this amazin lib! I have a very simple issue but i can't figured out how to solve it :/. I have a record like: { 'Jane Doe': 1, 'John Doe': 10 } and i want to pick the name of the highest score (ex: 'John Doe') ^^. Thanks !
Mike Lambert
@lax4mike
Jun 28 2018 14:13
hmm, objects are harder to work with than arrays, so you might want to look into R.toPairs and R.fromPairs
const getHighestName = R.compose(
  R.nth(0),
  R.reduce((highest, person) => highest[1] > person[1] ? highest : person, []),
  R.toPairs
)
maybe something like this
David Jegat
@Djeg
Jun 28 2018 14:25
Oh, great! I forget about this R.toPairs, it works like a charm, thanks!
Mike Lambert
@lax4mike
Jun 28 2018 14:25
:thumbsup:
Brad Compton (he/him)
@Bradcomp
Jun 28 2018 18:04
See also:
R.maxBy
Jai
@ramakrij
Jun 28 2018 18:44
Hello guys, Just started reading about Functional Programming and came across this library. It is just awesome. Well done team.
Mike Lambert
@lax4mike
Jun 28 2018 18:49
ahh, i haven't used maxBy
const getHighestName = R.compose(
  R.nth(0),
  R.reduce(R.maxBy(R.nth(1)), ["", -Infinity]),
  R.toPairs
)
but this works
Jai
@ramakrij
Jun 28 2018 18:50
Using Professor Frisby's mostly adequate guide to try out some examples. I understand Ramda has stopped supporting algebraic types and recommends Sanctury JS types (Maybe, Either). But how do I use them with out utility method S.toMaybe?
Is the recommendation to include the entire Sanctuary library along with Ramda?
Mike Lambert
@lax4mike
Jun 28 2018 18:58
i haven't really used sanctruary, but i think you use them side by side
there's also a new ADT library named crocks https://evilsoft.github.io/crocks/docs/crocks/
Brad Compton (he/him)
@Bradcomp
Jun 28 2018 19:00
Use Sanctuary if you want to have the run time type checking it provides
It's really powerful, but it can be too much if you aren't big on types.
Jai
@ramakrij
Jun 28 2018 19:02
Thanks. Will check the crocks library. from what I have looked so far, I want to just use Ramda with Maybe and Either types
But because there is no util functions like R.toMayBe and R.fromMayBe I have to use Sanctuary
Brad Compton (he/him)
@Bradcomp
Jun 28 2018 19:04
crocks is a good choice, as is folktale.
Jai
@ramakrij
Jun 28 2018 19:04
Thanks @Bradcomp Will take a look at those libs.