These are chat archives for ramda/ramda

18th
Oct 2018
Ben Briggs
@ben-eb
Oct 18 2018 13:40

Hello :) I was wondering if this is a bug or working as is:

propOr('-', 'a', { a: null }) // => null

Given what pathOr does (returns -) I would expect propOr to be consistent with that

Bijoy Thomas
@bijoythomas
Oct 18 2018 15:05
Bijoy Thomas
@bijoythomas
Oct 18 2018 15:10
I'm using ramda fantasy and am trying to filter only the Just's in an array of Maybe's. What's the right way to do this? I get how traverse and sequence will return a Nothing if there a Nothing in the array. How can I filter the [Maybe] to Just([elem..]) or [Just]?
Ben Briggs
@ben-eb
Oct 18 2018 15:13
@bijoythomas Thanks :+1:
Brad Compton (he/him)
@Bradcomp
Oct 18 2018 15:39
@bijoythomas I don't know for RF specifically, but is there a function or property like isJust you could use for filtering?
Daniel Gray
@DanielFGray
Oct 18 2018 15:46
in other libraries (like sanctuary) there is justs and mapMaybe, idk about RF either though
i've avoided RF since it's basically dead: "Ramda-Fantasy is no longer developed." https://github.com/ramda/ramda-fantasy#project-status
but looks like it does have an isJust property that you can use: https://github.com/ramda/ramda-fantasy/blob/master/src/Maybe.js#L17
Bijoy Thomas
@bijoythomas
Oct 18 2018 16:12
thanks @Bradcomp amd @DanielFGray .. I was wondering if there is equivalent for this function in Haskell: http://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Maybe.html#v:catMaybes
@DanielFGray thanks for the justs pointer .. looks like that is what I'm looking for .. I never quite made the jump from RF to Sanctuary. Maybe now is the time
Daniel Gray
@DanielFGray
Oct 18 2018 16:18
const justs = l => l.reduce((p, c) => p.concat(c.getOrElse([]))), []) or something, maybe
sanctuary's runtime type checking is really cool, and it has tons of great features, but i dislike how they removed auto-currying in the newer versions
no instance methods at all anywhere feels kinda weird
Daniel Gray
@DanielFGray
Oct 18 2018 16:26
though i guess it's objectively more Functional. idk, would've been nice to have .map and .pipe instance methods, a la flyd/rxjs
@bijoythomas should've pinged you with that example
Bijoy Thomas
@bijoythomas
Oct 18 2018 16:30
@DanielFGray no worries .. I got it .. thanks again
Daniel Gray
@DanielFGray
Oct 18 2018 16:31
np