These are chat archives for ramda/ramda

7th
Feb 2017
Kurt Milam
@kurtmilam
Feb 07 2017 13:46
What's the trick to making this work?
const makeDoAction = ( initializer ) => ( action ) => compose( always, action, initializer )
calling makeDoAction(init)(action) returns a function that returns a function, whereas I'm looking for it to return a function that returns a value.
Aldwin Vlasblom
@Avaq
Feb 07 2017 13:53
Remove always?
Kurt Milam
@kurtmilam
Feb 07 2017 13:58
@Avaq thanks for the tip - I'd forgotten to call the resulting function with a necessary input before passing it the input I want to ignore (using always)
Trying to abstract away as much as I can from this:
export const counter = ( state, action ) =>
  cond( [ [ isActionType( INIT ), doAction( set( counterLens, 0 ) )( state ) ]
        , [ isActionType( INCREMENT ), doAction( over( counterLens, inc ) )( state ) ]
        , [ isActionType( DECREMENT ), doAction( over( counterLens, dec ) )( state ) ]
        , [ isOtherwise, doAction( identity )( state ) ]
        ]
      )( action )
I'm thinking maybe I need to use something other than cond
I'd like to write a makeReducer function that takes an array of pairs [ actionName, actionFn ].
Aldwin Vlasblom
@Avaq
Feb 07 2017 14:03
Maybe you're not using it for a reason, but there's https://github.com/acdlite/redux-actions#handleactionsreducermap-defaultstate just in case you missed it.
Kurt Milam
@kurtmilam
Feb 07 2017 14:03
Thanks, I figured I was reinventing a wheel.
Aldwin Vlasblom
@Avaq
Feb 07 2017 14:04
It's good to realize that your doAction(f) actually returns another reducer (takes state and action and returns state).
And there are a lot of ways out there to compose reducers.
Kurt Milam
@kurtmilam
Feb 07 2017 14:06
Thanks, I'll take a look at both of those. Trying to cut down on boilerplate.
Aldwin Vlasblom
@Avaq
Feb 07 2017 14:07
redux-actions takes a lot of the boilerplate away from you.
Kurt Milam
@kurtmilam
Feb 07 2017 14:09
great, thank you for the pointer!
Ken Powers
@knpwrs
Feb 07 2017 16:50
Hey, guys. Quick question.
Is there a way to recursively rename keys?
Say, I have an object:
{
  foo_bar: {
    baz_qux: 'hello',
  },
}
And I want to make all the keys camelCase
As such:
{
  fooBar: {
    bazQux: 'hello',
  },
}
Ken Powers
@knpwrs
Feb 07 2017 17:12
Any way to do that point-free?
Denis Stoyanov
@xgrommx
Feb 07 2017 17:14
@knpwrs why do u need PF? It isn't panacea. Sometime usual lambda more readable than combinators (PF)
Ken Powers
@knpwrs
Feb 07 2017 17:15
Not a hard requirement by any means, just wondering.
Denis Stoyanov
@xgrommx
Feb 07 2017 17:16
@knpwrs f = \x y z w -> x * y + w / z vs f = flip flip (flip (/)) . (((.) . (.) . (+)) .) . (*)