These are chat archives for ramda/ramda

14th
Sep 2015
Scott Christopher
@scott-christopher
Sep 14 2015 00:00
If you were to use R.always(acc.concat(next).sort()), the concat and sort would evaluate every time, even if the ifElse predicate isn't satisfied.
Denis Stoyanov
@xgrommx
Sep 14 2015 00:04
@scott-christopher Yes I did it already)
Tobias Pflug
@gilligan
Sep 14 2015 09:31
@scott-christopher thanks!
Tobias Pflug
@gilligan
Sep 14 2015 09:39
@scott-christopher If i just want to play around with some arbitrary generators how do I actually get values out so that I could try things in the repl?
Scott Christopher
@scott-christopher
Sep 14 2015 10:04
@gilligan It looks like you can use jsc.sampler, e.g.
var objArb = jsc.dict(jsc.oneof(jsc.string, jsc.array(jsc.string)));
jsc.sampler(objArb)(R.identity);
// { '': [ 'ܜø', '˜–' ], 'p': [ '<³\u000f', '\u0006.' ], '¹/µ': '‰Ç' }
And to perform assertions:
jsc.assert(jsc.forall(objArb, obj => assert(something(obj))));
Tobias Pflug
@gilligan
Sep 14 2015 11:33
thanks again ;)
Aldwin Vlasblom
@Avaq
Sep 14 2015 13:25

I want to convert {email: "bob@example.com"} to {email: "bob@example.com", gravatar: "4b9bb80620f03eb3719e0a061c14283d"}. And I'm doing:

R.over(R.lens(R.prop("email"), R.assoc("gravatar")), emailToGravatarId)

But I feel like focusing the getter and setter of a lens on different parts of my data might be a bit hacky (non-idiomatic). I wonder what you guys think, and whether you can suggest an alternative?

Am I abusing lenses here, or is this just the thing they are meant to do?
Aldwin Vlasblom
@Avaq
Sep 14 2015 13:36
The reason I feel this might be abuse is because I wouldn't know what to name this lens; const emailAsAGetterButGravatarAsASetterLens = ...
Raine Virta
@raine
Sep 14 2015 13:44
emailGravatarLens?
depending on use, I may prefer
const setGravatarId = (obj) =>
  assoc('gravatar', emailToGravatarId(obj.email), obj);