These are chat archives for ramda/ramda

19th
Jan 2017
Adam Szaraniec
@mimol91
Jan 19 2017 11:01
Does ramda has similar function to assocPath but instead setting this value, it adds to an array ?
in case when key is empty its create an array with this one value ?
Martin Broder
@mrtnbroder
Jan 19 2017 14:01
hey folks
I'm trying to get rid of the (e) here
  mkUpdateHandler = (name, func) => (e) => R.converge(
    R.identity,
    [
      R.pipe(func, this.updateRoles(name)),
      this.handleOnAddExporter,
    ]
  )(this.getIdAndRoles(e))
but this is giving me an error somehow:
(name, func) => R.pipe(
    this.getIdAndRoles,
    R.converge(
      R.identity,
      [
        R.pipe(func, this.updateRoles(name)),
        this.handleOnAddExporter,
      ]
    )
  )
Cannot read property 'length' of undefined
Shane Keulen
@SeeThruHead
Jan 19 2017 14:11
if those functions access this you will need to bind them
Martin Broder
@mrtnbroder
Jan 19 2017 14:21
they are bound
Francisco López
@donflopez
Jan 19 2017 16:08
Hey, do use a documentation generator like jsdoc? I've seen dox, but do you use any other thing?
dcmwong
@dcmwong
Jan 19 2017 17:03
Hi, this feels like a silly question which I’m sure there’s an easy answer to. Given this https://goo.gl/Wd2Rw7 how do I make it run so that it doesn’t say test_data is undefined even though test_data doesn’t exist? In my real example it’s a function with a second parameter but I’m just testing for the second parameter not being passed without using an if (typeof(arg) === ‘undefined’)
Francisco López
@donflopez
Jan 19 2017 17:06
@dcmwong ^^^
dcmwong
@dcmwong
Jan 19 2017 17:08
I was looking at PipeK example on ramada docs however didn’t know where the Maybe.of came from. Thanks for the reply @donflopez :)
I need to require Maybe from there I take it?
Francisco López
@donflopez
Jan 19 2017 17:11
yes, and you can have a light error control with it
dcmwong
@dcmwong
Jan 19 2017 17:13
Why has Ramda not implemented some algebraic types and not others? eg. I can R.Either but not R.Maybe
dcmwong
@dcmwong
Jan 19 2017 17:18
Got to sign off now. Thanks again @donflopez . Still can’t get my example working but I might post something later.
Francisco López
@donflopez
Jan 19 2017 17:44
R.either is a function the other is a type @dcmwong
Ramda doesn't implement types
Scott Santucci
@ScottFreeCode
Jan 19 2017 18:15
either (the function from Ramda) vs. Either (the type from Ramda-Fantasy), right?
Francisco López
@donflopez
Jan 19 2017 18:45
That is the either function property from the Either type, I think that he is doing mention to R.either, same as me
Scott Santucci
@ScottFreeCode
Jan 19 2017 18:59
Yeah, I was trying to make explicit the distinction @donflopez and @dcmwong were discussing. Although the existence of an either function on an Either type certainly is worth taking into account too. :grin:
Matt Ross
@amsross
Jan 19 2017 19:53
R.assocPath(['existing', ‘path'], "new value”) vs R.set(R.lensPath(['existint’, ‘path']), "new value”)
I see that the source is very similar
R.set even calls back to R.assocPath
what is a basic case in which you would use one over the other?
Scott Santucci
@ScottFreeCode
Jan 19 2017 20:02
If I understand correctly: R.assocPath can only take paths; R.set can take any type of (writeable) lens. In a direct use like that example, they're interchangeable; the difference comes up if you want to separate the behavior from the path -- R.set generalizes that to separating the behavior from the structure, rather than requiring the type of structure to be a path.
Brad Compton (he/him)
@Bradcomp
Jan 19 2017 20:02
You would use a lens if you wanted to do more than just set. R.over is really helpful
Matt Ross
@amsross
Jan 19 2017 20:03
Yeah, I can definitely see the value of R.over and composed lenses
Brad Compton (he/him)
@Bradcomp
Jan 19 2017 20:04
If all you need to do on that path is to set a value, assocPath will get you there. Sometimes, though, you'll want to set a value, retrieve a value, and / or run a function over the value. a lens will give you that functionality
Matt Ross
@amsross
Jan 19 2017 20:04
Just curious if there was some implication at this level of simplicity that I was missing
ok, thanks for the info
:+1: !
Brad Compton (he/him)
@Bradcomp
Jan 19 2017 20:06
:bowtie:
dcmwong
@dcmwong
Jan 19 2017 20:52
@donflopez @ScottFreeCode I knew I’d be asking a silly question at some point :). Yes you are right I was getting mixed up the either function with the Either type. R.either simply takes into two functions and wraps them in a logical or || http://ramdajs.com/docs/#either