These are chat archives for ramda/ramda

15th
May 2017
Dennis Sivia
@scepticulous
May 15 2017 09:47
quick question. I want to implement a while loop via higher order functions. I was trying unfold at it works quiet well, except that I only want the final value of the result. Is there a way to do that, are there plans to have a more generic function than unfold ?
James Forbes
@JAForbes
May 15 2017 09:52
@scepticulous there was just a related discussion in the sanctuary gitter, chainRec is a stack safe, Monadic equivalent to a while loop. Not sure if that's helpful.
Dennis Sivia
@scepticulous
May 15 2017 09:55
thanks I will take a look
Dennis Sivia
@scepticulous
May 15 2017 10:02
@JAForbes thanks that looks nice. Would be nicer to have something related in ramda, however I guess I also should give sanctuary a try
Michael Rosata
@mrosata
May 15 2017 13:38
@scepticulous I think until works sort of as a while loop that returns the final value. It could probably handle a lot of situations that a while loop could
Dennis Sivia
@scepticulous
May 15 2017 13:40
fair point. I was so focussed on unfold that I forgot the obvious one. Thanks I will try my case with it.
Michael Rosata
@mrosata
May 15 2017 13:46
It seems like R.until would probably have difficulty performing a loop such as the one in the R.unfold doc example, because R.until differentiates between the iterator and the break condition, which to me feels "for loop-ish". R.until feels more "while loop-ish". Let me know how your case goes
Dennis Sivia
@scepticulous
May 15 2017 14:42
I will
Rick Medina
@rickmed
May 15 2017 15:54
@scepticulous I'm also curious about your use case
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:07
Hi all
I wrote some things to ramda.github.io room, but now I've noticed the last message in that room is too old
Michael Rosata
@mrosata
May 15 2017 19:08
@scriptype :wave:
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:09
is it ok if I just copy paste what I wrote there to here
about possible issues
or should I just open issues straight
Michael Rosata
@mrosata
May 15 2017 19:10
It's probably better to open an issue
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:10
thanks
I'm opening issues in ramda.github.io repository then
since they are about docs
Michael Rosata
@mrosata
May 15 2017 19:10
Then once you post the issue, it might be good to paste the link here
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:11
will do
Michael Rosata
@mrosata
May 15 2017 19:16
@scriptype If the error is coming from the inline documentation that is found in Ramdas source code (within comments above the functions declaration) then it could be better to put the issue in the main repo ramda/ramda, since the change would be made through that repo. If the error is likely part of the site template or in how the docs are generated then that would probably be best in the ramda/ramda.github.io repo
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:21
first one is this: ramda/ramda.github.io#177
I thought it was a docs mistake
apparently it was meant for http://ramdajs.com/docs/#__
but still, that's invalid code
Michael Rosata
@mrosata
May 15 2017 19:23
The __ is part of the R namespace
perhaps it would be better as R.__ in the docs
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:25
I think so
gt is written down as R.gt, for example
Michael Rosata
@mrosata
May 15 2017 19:25
yea, that would make sense, as everything else is prefixed with R
do you want the PR?
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:28
the other issue is this: ramda/ramda.github.io#178
looks like a simple correction, I can handle it
the last one is also a simple correction
I can handle both
Michael Rosata
@mrosata
May 15 2017 19:29
Alright awesome!
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:30
why should I open the first issue in the main repo?
edited: main repo
Michael Rosata
@mrosata
May 15 2017 19:35
you don't have to move the issue. Probably ok to just pull and edit the doc comment
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:37
actually, R.__ felt redundant to me, in that case
I guess it's there for ensuring the correct order of passed arguments
I can't imagine how that would work tho
Michael Rosata
@mrosata
May 15 2017 19:39
I think I lost you a little there
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:40
I mean, in the example of #where
I think you have it right, it should be namespaced in the doc
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:41
I mean, using R.__ or (in this case, mistakenly __) in this example feels redundant
I mean, beyond namespacing it
couldn't it be just lt(10), for instance
omitting R.__
Michael Rosata
@mrosata
May 15 2017 19:43
yea, I guess it must be the way the author likes to think of the comparison. I wish those two functions switched names to be honest :smile:
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:45
hmm, I don't know, I think I should go read more of the docs :D
Michael Rosata
@mrosata
May 15 2017 19:50
When I first started using R.gt and R.lt (and I still do this time to time), I think of R.filter(R.gt(10)) as to read like R.filter(n => n > 10) just because of the way I translate code into English in my head. Perhaps the person authoring the docs feels similar so they write R.filter(R.gt(R.__, 10)) so they can read as "filter where elementa are greater than 10". When my eyes focus on the R.gt, the words "greater than" are popping into my head no matter what
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 19:57
legit :D
pr: ramda/ramda#2178
and I'm closing the issue in the gh-pages repo
Michael Rosata
@mrosata
May 15 2017 19:59
I gave your PR a :thumbsup:, that's the full extent of my powers
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 20:00
lol
thanks
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 20:08
ramda/ramda.github.io#178
there's the dot in the source code, but not in the generated docs?
Michael Rosata
@mrosata
May 15 2017 20:13
That's weird. That could be an issue for ramda/ramda.github.io then. It looks like the period was just added in on Jan 12
Mustafa Enes Ertarhanaci
@scriptype
May 15 2017 20:16
looks like it isn't included in a new version yet
Gabe Johnson
@gabejohnson
May 15 2017 20:40

I wish those two functions switched names to be honest

@mrosata you might be interested in #2177

Joey Figaro
@joeyfigaro
May 15 2017 21:09
Hay folks. Anyone around here successfully created a partial match for strings? I'm shooting for a function that returns true given the following two strings: @@METRICS/GET, @@METRICS/GET/SUCCESS and false for these two: @@METRICS/GET, @@USERS/GET/SUCCESS
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:20
What about @@METRICS/GET/SUCCESS AND @@METRICS/POST/SUCCESS
or @@METRICS/GET/SUCCESS and @@METRICS/GET/FAILURE?
Joey Figaro
@joeyfigaro
May 15 2017 21:23
Good thinking. We don't currently have anything like POST, but it'd be good to consider it. I basically need to look at an incoming string and if it has a corresponding request string, I need to remove it from an array. I've got an array of requests that have been made, and as success types come in, I need to remove those request strings from there.
Could expand it in the future to handle things like POST
I'm not 100%, but I believe it's safe in the app I'm working on to assume that given an X/Y/SUCCESS string, I can remove X/Y and it'll work.
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:29
Joey Figaro
@joeyfigaro
May 15 2017 21:29
...I wasn't even close
hahhh
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:29
zipWith automatically truncates to the shorter list
so you can (is this hacky?) use it to compare initial substrings
Joey Figaro
@joeyfigaro
May 15 2017 21:31
Honestly, I'd prefer to add the corresponding request type to each action being fired... { type: '@@METRICS/GET/SUCCESS', meta: { origin: '@@METRICS/GET' } } and just compare that way.
But, that was the only other idea I had.
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:32
There's also...
R.init
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:33
which will take all but the last value of an array
Joey Figaro
@joeyfigaro
May 15 2017 21:34
Which would be useful on a split string?
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:34
@ram-bot
R.equals(R.split('/', '@@METRICS/GET'), R.init(R.split('/', '@@METRICS/GET/SUCCESS')))
ram-bot
@ram-bot
May 15 2017 21:34
true
Joey Figaro
@joeyfigaro
May 15 2017 21:34
Is identity a standin/alternative/complementary to __?
there it is
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:34
R.identity
Joey Figaro
@joeyfigaro
May 15 2017 21:34
that's beautiful
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:35
identity just returns what you give it
Joey Figaro
@joeyfigaro
May 15 2017 21:35
I saw the signature/explanation - curious why identity was used in your example with all
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:36
R.all(identity) just means all values in the array are truthy
Joey Figaro
@joeyfigaro
May 15 2017 21:36
That's neat
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:36
So in combo with the zipWith(equals) it will return true only if all the zipped values are equal
Like I said, it's a little hacky :stuck_out_tongue:
Joey Figaro
@joeyfigaro
May 15 2017 21:37
hehe
Thanks, dude.
Brad Compton (he/him)
@Bradcomp
May 15 2017 21:37
:bowtie:
Andrea Richiardi
@arichiardi
May 15 2017 22:52
Hello again folks!
For R.compose to work, do I need to "lift" normal js functions?
like kebabcase for instance
Brad Compton (he/him)
@Bradcomp
May 15 2017 23:01
No. compose should just work with normal JS functions
Andrea Richiardi
@arichiardi
May 15 2017 23:01
ok cool thanks @Bradcomp !