These are chat archives for ramda/ramda

16th
Jan 2019
Pranab Gupta
@Pranab16
Jan 16 08:17
Thanks @rakeshpai and @Bradcomp for your help, it makes sense.
Julien BONNIN
@Powerplex
Jan 16 10:39
Hello :) I was wondering if there was a method to "flatten a nested object" into its parent objet (I know I am not clear so I made an example) :
Is there a more direct approach to this ?
Julien BONNIN
@Powerplex
Jan 16 10:51
(I think a native approach is more clear :
const liftProp = (propName, obj) => {
const { [propName]: lifted, ...rest} = obj
return {...lifted, ...rest}
}
)
but maybe ramda has already a method for this ?
Brad Compton (he/him)
@Bradcomp
Jan 16 16:28
I use this typically:
const liftProp = (p, obj) => converge(merge, [prop(p), omit(p)])(obj);
martabrzeszczyk
@martabrzeszczyk
Jan 16 18:43

Hi, why partiallyAppliedState is not a function?

const setState = function(state){
  state.prop = "new prop"
}
const applyState = R.curry(setState)
var myState = {
    prop: "prop"
}
const partiallyAppliedState = applyState(myState)
partiallyAppliedState() // partiallyAppliedState  is not a function..

https://ramdajs.com/repl/?v=0.26.1#?const%20setState%20%3D%20function%28state%29%7B%0A%20%20state.prop%20%3D%20%22new%20prop%22%0A%7D%0Aconst%20applyState%20%3D%20R.curry%28setState%29%0Avar%20myState%20%3D%20%7B%0A%20%20%20%20prop%3A%20%22prop%22%0A%7D%0Aconst%20partiallyAppliedState%20%3D%20applyState%28myState%29%0ApartiallyAppliedState%28%29%20%2F%2F%20partiallyAppliedState%20%20is%20not%20a%20function..

Ben Briggs
@ben-eb
Jan 16 19:12
@martabrzeszczyk It's because setState and applyState by extension are unary (1 argument functions) and by calling applyState with myState you already ran the function :)
Ben Briggs
@ben-eb
Jan 16 19:42
@martabrzeszczyk If you wanted to delay evaluation you could wrap it:
const partiallyAppliedState = R.thunkify(applyState)(myState)
partiallyAppliedState()
Suleyman Melikoglu
@laplacesdemon
Jan 16 20:04
Hi everyone :) I was wondering why compose accepts functions as arguments but functions created by composeWith wants an array of functions. Like following: compose(inc, inc) and const myCompose = composeWith(...); myCompose([inc, inc]).
Brad Compton (he/him)
@Bradcomp
Jan 16 20:07
@laplacesdemon Check out the earlier discussion here: https://gitter.im/ramda/ramda?at=5c36f2d02e25e453d75adc11
Suleyman Melikoglu
@laplacesdemon
Jan 16 20:12
Thanks @Bradcomp