These are chat archives for ramda/ramda

Jan 2017
Brad Compton (he/him)
Jan 07 2017 00:15
@jethrolarson See the referenced discussions here
James Forbes
Jan 07 2017 10:38

Say you have a lensProp('x'), and you want to ensure that any R.set call will always run parseIntover the input first.

Is there a way to compose only to the set of an existing lens?

wait got it, was thinking about it all backwards
I can just compose the get so its as if it was converted to a number when it was received
var numberLens = lens(Number, Number)
var o = { value: '3' }

var valueLens =  lensProp('value')
var numberLens = lens(Number, identity)

var x = compose(valueLens, numberLens)
R.view(x, o)
James Forbes
Jan 07 2017 10:47
oh right you can compose lens(identity, Number) as well to intercept any sets, this is so cool I don't know why I was so scared of lenses
Hardy Jones
Jan 07 2017 15:12
I'm confused. The types of numberLens don't seem to line up.
Tobias Pflug
Jan 07 2017 22:17
Don't get that either. Seems wrong (?)
James Forbes
Jan 07 2017 23:12

Yeah I'm probably misunderstanding something. My thinking was the set callback in the lens initializer accepts the new value and then the existing value.
And in the case of a primitive value I only want that 1st argument so I just used identity

What would be the correct way to parse numbers that are received via a lens via R.set?