These are chat archives for ramda/ramda

4th
Apr 2018
Scott Sauyet
@CrossEye
Apr 04 2018 00:43
@laxmike: These days, I don't think we'd even include it. It's just too easy to use lambdas for this.
lee_zhou_cn
@lizhoulee
Apr 04 2018 04:24

// get :: String -> Object -> Maybe *
var get = R.curry((propName, obj) => Maybe(obj[propName]))

// getStateCode :: Maybe String -> Maybe String
var getStateCode = R.composeK(
R.compose(Maybe.of, R.toUpper),
get('state'),
get('address'),
get('user'),
);
getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY")
getStateCode({}); //=> Maybe.Nothing()

Which Maybe library should I choose?

Jacob Madsen
@jacobmadsen
Apr 04 2018 11:13
Which TypeScript package should I use? types/npm-ramda#dist or @types/ramda ?
Arbaaz
@arbaaz
Apr 04 2018 11:26
@lizhoulee R.path(['user', 'address', 'state'])
Brad Compton (he/him)
@Bradcomp
Apr 04 2018 15:26
@lizhoulee I've used Sanctuary and Folktale. Sanctuary is much more opinionated, and works really well if you want the ADTs along with utility functions, and a run time type system that's on by default. If you're just looking for a Maybe implementation I've used folktale quite a bit and I like it. I think crocks is also worth checking out, but I haven't had a chance to try it out yet.
lee_zhou_cn
@lizhoulee
Apr 04 2018 16:12
@arbaaz @Bradcomp thank you !