These are chat archives for ramda/ramda

7th
Oct 2015
shakrah yves
@syves
Oct 07 2015 00:24
Hello ramda lover. Do any of you use ramda at work, in San Francisco?
Lovers , rather. I’m looking for a junior dev or tech support role at such a company
If you use any functional language at work please tell us about it, even if you are not in the bay area!
boxofrox
@boxofrox
Oct 07 2015 00:54
There's no inverse for concat like how append has prepend? Just flip it, right?
Scott Christopher
@scott-christopher
Oct 07 2015 00:55
Yeah, just R.flip(R.concat)
Or if you have the second arg, R.concat(R.__, secondArg)
boxofrox
@boxofrox
Oct 07 2015 00:59
Thanks @scott-christopher .
Niloy Mondal
@niloy
Oct 07 2015 06:38
Hey whats with the chain function name, what exactly are we chaining? Why not simply call it flatMap
Raine Virta
@raine
Oct 07 2015 06:51
@niloy to be consistent with Fantasy Land
Niloy Mondal
@niloy
Oct 07 2015 06:51
Fantasy Land???!!! Let me google it
Raine Virta
@raine
Oct 07 2015 06:58
logo.png
where unicorns prance around
Niloy Mondal
@niloy
Oct 07 2015 07:06
Ramda should include a print function to log stuff.. like forEach(print, [1,2,3])
Raine Virta
@raine
Oct 07 2015 07:07
what's wrong with console.log?
Niloy Mondal
@niloy
Oct 07 2015 07:07
console.log requiers thisto work
Raine Virta
@raine
Oct 07 2015 07:08
only in node
Niloy Mondal
@niloy
Oct 07 2015 07:08
And Chrome
Raine Virta
@raine
Oct 07 2015 07:08
sorry, in node it doesn't
Niloy Mondal
@niloy
Oct 07 2015 07:08
The primary browser I use for development
Raine Virta
@raine
Oct 07 2015 07:08
in browser it does
Niloy Mondal
@niloy
Oct 07 2015 07:08
yeh :(
Raine Virta
@raine
Oct 07 2015 07:08
var print = console.log.bind(console);
Niloy Mondal
@niloy
Oct 07 2015 07:09
yeh, I am suggesting it would be nice if it comes out of the box
Raine Virta
@raine
Oct 07 2015 07:12
I see. ramda doesn't really like side-effects
currently I think R.forEach is the only function that supports side-effects
Niloy Mondal
@niloy
Oct 07 2015 07:15
Yes, I get that. But a little convenience doesn't hurt :)
Raine Virta
@raine
Oct 07 2015 07:18
I suggest you open an issue on that
Niloy Mondal
@niloy
Oct 07 2015 07:18
Ok, will do that.
Raine Virta
@raine
Oct 07 2015 07:21
I think it's unlikely that print would find its way to ramda but you get to voice your concerns to wider audience
Niloy Mondal
@niloy
Oct 07 2015 07:21
👍
Raine Virta
@raine
Oct 07 2015 07:25
which editor do you use?
Niloy Mondal
@niloy
Oct 07 2015 07:25
Sublime Text
Raine Virta
@raine
Oct 07 2015 07:26
I use vim with mappings that surround functions with require('treis')(fn) and find it very useful for debugging
Niloy Mondal
@niloy
Oct 07 2015 07:27
👍 Will try it out
Dave Keen
@ccapndave
Oct 07 2015 08:23
Morning everyone. Is there any way to track where errors actually occur in an Rx chain? I just got an error like this, which is totally unhelpful and doesn't tell me where in the code the error actually occurs:
Error: Parser is unable to parse the response
throwerrx.all.js:70
errorrx.all.js:10044
onErrorrx.all.js:1720
onErrorrx.all.js:1944
onErrorrx.all.js:10275
handlerrx.all.js:6425
callbackclient.js:841
(anonymous function)client.js:475
emitindex.js:133
onreadystatechangeclient.js:918
I've done (Rx.config as any).longStackSupport = true;, but it doesn't seem to make any difference
Andreas Møller
@cullophid
Oct 07 2015 09:45
Can anyone tell me why the second param in R.range is exclusive ?
Niloy Mondal
@niloy
Oct 07 2015 09:47
Thats how most range work in other languages
Andreas Møller
@cullophid
Oct 07 2015 09:48
@niloy Is there any reasoning behind this, or is it just convension?
Martin Algesten
@algesten
Oct 07 2015 09:49
works quite well in combination with array length, string size etc.
Andreas Møller
@cullophid
Oct 07 2015 10:00
yes but it does sacrifice an intuitive interface ...
Thanks for the answer :)
Niloy Mondal
@niloy
Oct 07 2015 10:08
Do you think its better to use x => x instead of R.identity?
Martin Algesten
@algesten
Oct 07 2015 10:09
i asked the same a little while back. @raine preferred R.identity
i fell in line :)
Niloy Mondal
@niloy
Oct 07 2015 10:09
:D
Raine Virta
@raine
Oct 07 2015 10:39
algesten: your question was about R.always
Martin Algesten
@algesten
Oct 07 2015 10:40
@raine tomato tomaaato?
:)
or do you feel differently for this case?
Niloy Mondal
@niloy
Oct 07 2015 10:40
:D
Raine Virta
@raine
Oct 07 2015 10:41
in this case I feel more strongly towards using identity
Martin Algesten
@algesten
Oct 07 2015 10:42
great. i was worried you were going to argue the other way around here :)
Scott Sauyet
@CrossEye
Oct 07 2015 11:06
always and identity are very different functions. always is more like x => (y => x) or x => (* => x).
Martin Algesten
@algesten
Oct 07 2015 11:07
yes. but it's sort of the same principle. with ES6 we could chose to write () => 42 instead of R.always(42) or x => x instead of R.identity. The question which is more obvious to the reader?
Raine Virta
@raine
Oct 07 2015 11:20
words are easier to associate to patterns than syntax
IMO
Scott Sauyet
@CrossEye
Oct 07 2015 11:24
While I agree in general, I do find that both of these functions are on the borderline. The syntax is a chose runner-up in each case.
Aldwin Vlasblom
@Avaq
Oct 07 2015 11:25
The worded versions are a better conveyor of developer intent in my opinion.
They convey "I did this on purpose" a lot better than seemingly noop lambda's.
Raine Virta
@raine
Oct 07 2015 11:30
yes
Scott Sauyet
@CrossEye
Oct 07 2015 11:44
I feel that way more so about always. I guess identity simply doesn't do this add well for me. I was happier doing so when we had the alias of I, and I could think about it as the combinator. identity feels as though it might have other meanings: return the identity property of the item.
Frederik Krautwald
@Frikki
Oct 07 2015 12:03
Is identity supposed to reflect identity in Category Theory?
Scott Sauyet
@CrossEye
Oct 07 2015 12:17
Identity is just x => x
Frederik Krautwald
@Frikki
Oct 07 2015 12:22
That is identity in Category Theory.
David Chambers
@davidchambers
Oct 07 2015 16:01

@CrossEye, I'd like to understand why

R.filter(q, R.filter(p, x)) ≍ R.filter(p, R.filter(q, x))

demonstrates commutativity (rather than associativity). I spent some time reading Wikipedia and the FL spec in order to determine which is correct. I found it difficult to be sure since the concepts apply to binary operators.

Infix notation makes the situation a little clearer:

q `filter` (p `filter` x) ≍ p `filter` (q `filter` x)

The above shows that filtering x by p, then filtering the result by q is equivalent to filtering x by q, then filtering the result by p.

The following shows that adding 2 to 3, then adding 4 to the result is equivalent to adding 4 to 3, then adding 2 to the result:

(2 + 3) + 42 + (3 + 4)

If commutativity means that changing the order of the operands of a binary operation does not change the result, wouldn't it require the following?

p `filter` x ≍ x `filter` p

What am I missing or misunderstanding?

Niloy Mondal
@niloy
Oct 07 2015 16:19
R.filter(q, R.filter(p, x)) ≍ R.filter(p, R.filter(q, x)) Thats associative
This message was deleted
Commutative would be R.filter(x, q)
Scott Sauyet
@CrossEye
Oct 07 2015 17:29

@davidchambers : Maybe I'm thinking about it wrong, but this is what I would think about as commutative:

f ∘ g  = g ∘ f 

So this is a demonstration of commutativity:

filter(f) ∘ filter(g) ≍ filter(g) ∘ filter(f)

This would take some work to demonstrate for a given implementation of filter.

But associativity would be the property that

filter(f)(filter(g)(filter(h))) ≍ (filter(f)(filter(g)))(filter(h))

You definitely cannot demonstrate associativity with only two entities.

Scott Sauyet
@CrossEye
Oct 07 2015 17:51
Lovely. Those were composition operators and an apprpximately equals sign.
David Chambers
@davidchambers
Oct 07 2015 19:07
Hmm, okay. Well, the order in which filters are applied does not influence the result is a property of filter whether or not we know what to call it. :wink2:
Scott Sauyet
@CrossEye
Oct 07 2015 19:20
Sounds good. :wink: