These are chat archives for ramda/ramda

10th
Feb 2017
Just RAG
@justrag
Feb 10 2017 11:51
How to increase the deep value?
const thing={a: {b: {c:7}}};
R.assocPath(['a','b','c'], R.compose(R.inc,R.path(['a','b','c']))(thing), thing)
works, but does not seem like the shortest way.
Denis Stoyanov
@xgrommx
Feb 10 2017 11:59
@justrag evolve?
@justrag evolve({a:{b:{c:inc}}})
@ram-bot
R.evolve({a:{b:{c:R.add(1)}}})({a: {b: {c:7}}})
ram-bot
@ram-bot
Feb 10 2017 12:00
{ a: { b: { c: 8 } } }
Just RAG
@justrag
Feb 10 2017 12:00
Blimey, forgot about it again. :)
@ram-bot R.evolve({a:{b:{c:R.inc)}}})({a: {b: {c:7}}})
Thanks!
ram-bot
@ram-bot
Feb 10 2017 12:15
Unexpected token )
Kurt Milam
@kurtmilam
Feb 10 2017 17:08
Any tips on working with global state when it's a requirement, and/or getting rid of it completely?
For instance, when branching based on process.env.NODE_ENV or on some global set by a third party on window?
I'm so used to eschewing globals that I'm flummoxed about how to work with them in a functional style when they come from a third party.
Should I just hold my nose and be imperative for a few lines of code?
Pygmalion
@PygmalionPolymorph
Feb 10 2017 17:13
Maybe you can wrap it in a stream, which you then can treat as if it was a function returning the state
Rick Medina
@rickmed
Feb 10 2017 17:20
@kurtmilam without knowing the specifics, yeah why not a function that just gets the value? If you are worried about it being not deterministic you can always consider monadic stuff
Kurt Milam
@kurtmilam
Feb 10 2017 17:56
@rickmed: I may just be trying to use Ramda to hide conditionals from Istanbul during testing.
Istanbul doesn't know that ifElse is a conditional that should have both branches tested :D
So maybe I shouldn't rely on coverage reports its giving me.
Rick Medina
@rickmed
Feb 10 2017 18:02
@kurtmilam If I'm getting it right, what not use istanbul comments?
*why
Kurt Milam
@kurtmilam
Feb 10 2017 18:03
@rickmed: I'd actually like to have the coverage.
Keith Alexander
@kwijibo
Feb 10 2017 18:09
@kurtmilam re globals, what about using Reader monad?
Rick Medina
@rickmed
Feb 10 2017 18:10
@kurtmilam Sorry, I think I'm helpless bc I'm lost. You would like to hide conditionals from istanbul but have them covered? :expressionless:
Kurt Milam
@kurtmilam
Feb 10 2017 18:15
@kwijibo I'll read up on the Reader monad.
@rickmed sorry, I'm meandering a bit. My initial goal was to get coverage for some third-party code that relies on globals. I refactored the code using Ramda and realized that Istanbul stopped complaining about the lack of coverage. At first, I thought that was great - 'hey, just by refactoring to use Ramda, the need for tests there disappeared'. Then I realized it was more likely that I'd just fooled Istanbul rather than removing the coverage gaps.
Kurt Milam
@kurtmilam
Feb 10 2017 18:21
@rickmed & @kwijibo Thanks for the links. I will read both.
Drew
@dtipson
Feb 10 2017 19:10
    Function.prototype.chain = function(f) {
        return x => f(this(x))(x)
    }
^ I'm still trying to wrap my head around how, apparently, that's basically Reader
Denis Stoyanov
@xgrommx
Feb 10 2017 19:36
monad via combinators
const MO = B1(W)(B);
const MO1 = B(B(W))(B);
Denis Stoyanov
@xgrommx
Feb 10 2017 19:43
@dtipson yes, because you are reading from a constant storage for every step of monadic chain
Drew
@dtipson
Feb 10 2017 20:34
that information will probably make sense to me one day, but it still doesn't get me there. I can see the raw similarity
Reader.prototype.chain = function(f) {
  return new Reader( r => f(this.run(r)).run(r) );
};
but I don't understand the implications
Brasycad master
@brasycad
Feb 10 2017 20:56
does anyone know why 'var groupByUser = .partition(.prop('username'));' of documentation example dont work for me?
Rob Hilgefort
@rjhilgefort
Feb 10 2017 22:09
Is there an opposite for equals?
or would I just need to pipe(equals(‘foo’), not)?
Denis Stoyanov
@xgrommx
Feb 10 2017 22:11
only compose with predicate and not
Rob Hilgefort
@rjhilgefort
Feb 10 2017 22:13
kk
Brad Compton (he/him)
@Bradcomp
Feb 10 2017 22:45
R.complement