These are chat archives for ramda/ramda

Aug 2016
James Forbes
Aug 21 2016 01:59

@olsonpm my pleasure

eh, isn't chain map and chain simultaneously?

I could have been a lot clearer when I said that.

R.chain( multiply(2) , 2 ) //=> undefined multiply(2), 2 ) //=> 4

R.chain( multiply(2) , [2] ) //=> 4 multiply(2), [2] ) //=> [4]

The behaviours of map and chain are explicit. Chain transforms and unwraps, map only transforms.

chain requires the output of the visitor to be a monad, map expects the output of the visitor to be a value

Meanwhile then handles both cases, if you return a Promise, then the next .then will receive a value (like chain) and if you return a value, the next .then will receive a value (like map). This doesn't really seem to matter for promises because the Promise API is specific to Promises.

But if Promise's used map and chain and didn't automatically squash containers, we could compose Promises easily with other monad's ( like streams for example). Currently that is awkward, but it didn't have to be.

I think the A+ spec didn't account for more and more monadic types entering the language and interop being important.
It is likely we'll have Observables (can't stand that name) soon. And there will probably be more Monads added as the language evolves. It is forseeable after Observables we will get a synchronous Optional/Result/Maybe type as that is now pretty standard even in OO languages like C# and Java.

It is a shame that each API will probably be an island.

Ryan Zeigler
Aug 21 2016 02:03
wait, map can operate on strict values?
does it asume the Ident functor?
Observables are weird, because there are 2 chain/bind analogs, mergeMap and switchMap
James Forbes
Aug 21 2016 02:05
@arzig I was surprised by that too
Ryan Zeigler
Aug 21 2016 02:08
mergeMap does more of what I would expect it to do as it won't lose values
i feel like some actual FRP toolkits just don't expose the monad because its either nonsensical or too confusing
but that's something I'm still learnign about
James Forbes
Aug 21 2016 02:09
what is the difference between mergeMap and switchMap? Is that RxJS terminology?

Seems like most.js makes the same distinction you are making in its chain implementation

concatMap concatenates, while chain merges.

Aug 21 2016 03:32

is there a comprehensive reason for select functions in the list category working with objects as well as arrays? I didn't realize some of the function signatures are wrong until now (declare Array when object works fine).

for example, why won't forEach take an object but filter will?

Ryan Zeigler
Aug 21 2016 14:44
@JAForbes mergeMap merges emitted observables having n active received at a time, switchMap only takes the latest
in older APIs mergeMap(f, 1) is equivalent to flatMap and switchMap(f) is equivalent to flatMapLatest
to get actually multiple observables out of the operator you had to explicitly merge with a parallelism factor
not sure if that clears it up