These are chat archives for ramda/ramda

15th
Sep 2017
Julio Borja Barra
@juboba
Sep 15 2017 09:26
why does map work on plain objects? I thought it just dispatched the map method on the data argument.
Stefano Vozza
@svozza
Sep 15 2017 09:27
it treats objects as a functor
Julio Borja Barra
@juboba
Sep 15 2017 09:29
plain javascript objects are not functors
it's useful, but it's weird
Stefano Vozza
@svozza
Sep 15 2017 09:34
here is the reasoning:
ramda/ramda#1426
Julio Borja Barra
@juboba
Sep 15 2017 09:50
oh
an Object is a Functor?
I thought it needed to implement a map method (satisfying identity, .....)
Brad Compton (he/him)
@Bradcomp
Sep 15 2017 15:21
An object isn't necessarily a functor, but it can be treated as one if you look it as a Dict<String, A>. The map function Ramda implements for Objects satisfies the two laws in that case.
Julio Borja Barra
@juboba
Sep 15 2017 16:39
I see
Konstantin Kostiuk
@SET001
Sep 15 2017 23:22
hi all
are there anything like this in ramda
const invoke = (method, param?) => object =>{ object[method](param); return object }
I need something like R.invoker but that would return given object, not the result of invocation
so I can use in compose
compose(
    map(invoker(1, 'start')(new rx.ReplaySubject())),
    map(invoker(0, 'init'))
)([
    loggerFactory(),
    container.getNamed('Module', 'Game'),
    container.getNamed('Module', 'Multiplayer'),
])
Dmitry
@zerobias
Sep 15 2017 23:28
Combine invoker with tap
Konstantin Kostiuk
@SET001
Sep 15 2017 23:35

like this

const blah = what => obj =>    tap(what)(obj)

compose(
    map(blah(invoker(1, 'start')(new rx.ReplaySubject()))),
    map(blah(invoker(0, 'init')))
)([
    loggerFactory(),
    container.getNamed('Module', 'Game'),
    container.getNamed('Module', 'Multiplayer'),
])

?

or can be done without blah?
oh
compose(
    map(tap(invoker(1, 'start')(new rx.ReplaySubject()))),
    map(tap(invoker(0, 'init')))
)([
    loggerFactory(),
    container.getNamed('Module', 'Game'),
    container.getNamed('Module', 'Multiplayer'),
])
Darren
@dardub
Sep 15 2017 23:43
Got an easy one: ^_^ https://goo.gl/XGqkB7
What am I not understanding here?
Kevin Wallace
@kedashoe
Sep 15 2017 23:45
2nd param to when is a function
map( when(isNil, always('')) , a)
Darren
@dardub
Sep 15 2017 23:45
ah. damn
ty.
Kevin Wallace
@kedashoe
Sep 15 2017 23:46
:+1:
Darren
@dardub
Sep 15 2017 23:51
Since I'm here, is there common way of performing the above, since it seems like a pretty common operation? :D
Kevin Wallace
@kedashoe
Sep 15 2017 23:57
you could use defaultTo
map( defaultTo('') , a)
Darren
@dardub
Sep 15 2017 23:58
Ah. Nice. I feel like I need to read through every single function available. But I know I won't be able to remember it all anyways..
So far I've mostly relied on the cookbook and what function do I use.