These are chat archives for ramda/ramda

20th
Jun 2016
LeonineKing1199
@LeonineKing1199
Jun 20 2016 15:18
Don't reduce concat calls when there's chain right there :)
Aldwin Vlasblom
@Avaq
Jun 20 2016 16:09
Whoops :)
Tushar Mathur
@tusharmath
Jun 20 2016 16:09
I am trying to understand Lenses as defined here — https://github.com/ramda/ramda/blob/master/src/lens.js, Can someone tell me how does a lens know if the setter is supposed to be called or the getter
Brad Compton (he/him)
@Bradcomp
Jun 20 2016 16:09
@tusharmath The setter gets called when you use set and the getter gets called when you use view
Using over first uses get to attain the current value, then runs the function you pass to it, then calls set with the result
Tushar Mathur
@tusharmath
Jun 20 2016 16:11
But the setters and getters are passed inside lens as an arg.
module.exports = _curry2(function lens(getter, setter) {
  return function(toFunctorFn) {
    return function(target) {
      return map(
        function(focus) {
          return setter(focus, target);
        },
        toFunctorFn(getter(target))
      );
    };
  };
});
@Bradcomp Does it mean, get is always called, even when I want to set ?
Brad Compton (he/him)
@Bradcomp
Jun 20 2016 16:12
I haven't spent much time in the implementation details, but typically you don't call the lens directly, but instead use view and set with the lense
set
Tushar Mathur
@tusharmath
Jun 20 2016 16:14
I understand superficially what view and set is doing. I want to understand how is it actually implemented.
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:26
Well, good news for you is that the ramda api docs have direct links to their implementations!
I realize that may sound sarcastic. It's not meant to be.
Here's the one for set.
I don't blame you for wanting to see the implementations either. That's how I learn as well.
Denis Stoyanov
@xgrommx
Jun 20 2016 16:49
Can I use lenses like a functor, applicative functor, monad, composition as in haskell?
Barton Petersen
@bpetersen
Jun 20 2016 20:04
I'm looking to wrap a function that already returns a promise into a Ramda-Fantasy Future. Is this how I should do that?
const futureGet = url => { return new Future((reject, resolve) => { axios.get(url).then(result => resolve(result.data), err => reject(err)) }) }
Aldwin Vlasblom
@Avaq
Jun 20 2016 20:05
Barton Petersen
@bpetersen
Jun 20 2016 20:40
Oh, nice @Avaq , thank you for that :)