These are chat archives for ramda/ramda

12th
Oct 2017
Oskar Koli
@Havdon
Oct 12 2017 12:10

Does there exist a function in Ramda that takes an object, function and prop and returns the object with the prop updated using the function?

My own implementation:
const overProp = R.curry((key, fn, obj) => R.over(R.lensProp(key), fn, obj))
Usage:
overProp('key', (key) => key + 1, { key: 0, other: 0 }) === { key: 1, other: 0 }

Asking, because it feels like this is something that might already exist but I'm just not finding it in the docs?

James Forbes
@JAForbes
Oct 12 2017 12:29
evolve is sort of this too
Kurt Milam
@kurtmilam
Oct 12 2017 12:39
@Havdon In addition to evolve, there's been some recent discussion about adding a dedicated function. ramda/ramda#2317
Oskar Koli
@Havdon
Oct 12 2017 12:47
Cool, thanks guys
Jethro Larson
@jethrolarson
Oct 12 2017 15:23
R.o is redundant with map, right?
Michael Rosata
@mrosata
Oct 12 2017 15:25
@jethrolarson they shouldn't be, are you looking at a particular example?
arian‮
@arian-swydo
Oct 12 2017 15:27
R.o is love, R.o is life
Michael Rosata
@mrosata
Oct 12 2017 15:30
@arian-swydo if R.o -> love and R.o -> life, then R.o would have to wrapped in IO Monad
for purity sake
arian‮
@arian-swydo
Oct 12 2017 15:31
R.o is one of the most versatile functions in the library: Tired of other people commenting on the readability of your code? R.o. Worried your colleagues will easily see the glaring bug in your code? R.o. ESLint says you can't mutate a function parameter? R.o. Your wife left you and she's going to sue you for alimony? R.o
(I have no clue what I'm talking about)
Michael Rosata
@mrosata
Oct 12 2017 15:39
sounds good enough to me
arian‮
@arian-swydo
Oct 12 2017 15:41
R.o is like the kid who nobody invited and at this point he seems to be getting along so well, everyone is gonna assume somebody must know him
Yosbel Marín
@yosbelms
Oct 12 2017 15:45
0.25.0 breaked up some things
ramda/ramda#1980
to require from ramda/src/... is not safe any more
arian‮
@arian-swydo
Oct 12 2017 15:47
hmmm
I just updated to 0.25, didn't have anything break yet
is there any module in specific that stopped working?
Michael Rosata
@mrosata
Oct 12 2017 15:49
sounds like they should work for the moment but it is better to use ramda/<function_name> over ramda/src/<function_name> as the latter is being removed in later versions.
I don't know if any are broke though, I haven't yet had trouble. Now that I know however, I'm going to make the switch. Thanks @yosbelms
Yosbel Marín
@yosbelms
Oct 12 2017 16:45
@arian-swydo , @mrosata Actually 0.25 works as expected with ramda/src/.. but as @mrosata pointed above is time to move to ramda/<function_name>. It didn't break anything yet, but I suppose 0.25 deprecates the former way of importing.
Philipp Wille
@Yord
Oct 12 2017 16:57

@Havdon Another implementation (and for the sake of R.o awesomeness):

const overProp = uncurryN(3, o(o)(o)(evolve)(objOf))

const obj = { a: 1, b: 2 }
overProp('b', inc, obj) // {"a": 1, "b": 3}
overProp('b')(inc, obj) // {"a": 1, "b": 3}
overProp('b', inc)(obj) // {"a": 1, "b": 3}
overProp('b')(inc)(obj) // {"a": 1, "b": 3}

:) Love me some R.o!

Konstantin Kostiuk
@SET001
Oct 12 2017 17:11
I have an array of functions and I would like to run then all one by one, passing same parameter to them. What is the ramda way for doing this?
Philipp Wille
@Yord
Oct 12 2017 17:13
@SET001 Have a look at juxt!
const fs = [inc, dec]

juxt(fs)(1) // [2, 0]
@ram-bot
juxt
ram-bot
@ram-bot
Oct 12 2017 17:14
[Function: f1]
Konstantin Kostiuk
@SET001
Oct 12 2017 17:14
yeah, seems like exactly what I need
@Yord thanx
Philipp Wille
@Yord
Oct 12 2017 17:15
:wave:
(btw. how do you use ram-bot anyway?)
@ram-bot
juxt
ram-bot
@ram-bot
Oct 12 2017 17:17
[Function: f1]
Paul
@pauloliver
Oct 12 2017 17:20
@ram-bot
R.juxt
ram-bot
@ram-bot
Oct 12 2017 17:20
[Function: f1]
Philipp Wille
@Yord
Oct 12 2017 17:24
@ram-bot
R.map
ram-bot
@ram-bot
Oct 12 2017 17:24
[Function: f2]
Philipp Wille
@Yord
Oct 12 2017 17:24
appears to be broken (?)
Kurt Milam
@kurtmilam
Oct 12 2017 17:51
Not to spam, but if you'd like to see support for currying in jsdoc, please head over here and add your vote: jsdoc3/jsdoc#1286
Inspired by this recent Ramda issue: ramda/ramda#2335
arian‮
@arian-swydo
Oct 12 2017 17:55
I've always just done @implements {CurriedFunction}
Kurt Milam
@kurtmilam
Oct 12 2017 17:56
I'll have to look up @implements to see how that works.
arian‮
@arian-swydo
Oct 12 2017 18:00
well my reasoning was that if I were to annotate it in Typescript, I would declare a CurriedFunction type or interface, so then I would assume @implement would be the correct way to annotate those
but I haven't written Typescript in a year, thus I'm not sure if the implementation would really work
perhaps looking at TS definition file for ramda might shed some light on how they've annotated curry
arian‮
@arian-swydo
Oct 12 2017 18:07
(doesnt fix type checking obviously, but helps with generating docs)
Denis Stoyanov
@xgrommx
Oct 12 2017 20:59
@SET001 converge(unapply(identity))([add(10), add(20)])(1)
Michael Hurley
@buzzdecafe
Oct 12 2017 21:18
alternative to juxt solution is ap:
const fs = [inc, dec]

ap(fs, [1])