These are chat archives for ramda/ramda

11th
Jun 2015
John-David Dalton
@jdalton
Jun 11 2015 00:28
The npm folks (people) are really nice.
Scott Christopher
@scott-christopher
Jun 11 2015 05:59
Is there a function already in Ramda that simply converts its arguments to an array?
I guess R.unapply(R.identity) will do the trick.
Raine Virta
@raine
Jun 11 2015 06:30
scott-christopher: yep, it's even on the cookbook https://github.com/ramda/ramda/wiki/Cookbook#create-a-list-function
Simon Friis Vindum
@paldepind
Jun 11 2015 07:30
@jethrolarson If you think there are cases in the Snabbdom source that needs comments you're welcome to do a PR. To me it reads quite well though. But I am not everybody of course.
@joneshf Not really. It modifies listeners as well. It creates a closure with an initial count. Every time the function is called the count is decremented. When it reaches zero the element is removed.
Robert Balfre
@rob-balfre
Jun 11 2015 09:44
Does ramda have a function to check if an object has a key? Can't seem to find one if it does.
Raine Virta
@raine
Jun 11 2015 09:51
rob-balfre: has :)
Robert Balfre
@rob-balfre
Jun 11 2015 09:56
haha of course, thanks.
Hardi Kõvamees
@luminarious
Jun 11 2015 13:52
More competition, it seems.. https://github.com/jussi-kalliokoski/trine
Raine Virta
@raine
Jun 11 2015 16:12
in the category of neat stuff you can do with ramda-cli: Merge data from multiple json files
Scott Sauyet
@CrossEye
Jun 11 2015 16:44
At first look, Trine seems closer in spirit to Underscore / lodash.
Very nice, as always, @raine !
Raine Virta
@raine
Jun 11 2015 16:46
thought so too. ramda was name-dropped though
Raine Virta
@raine
Jun 11 2015 16:55
ah, CrossEye you commented on HN: https://news.ycombinator.com/item?id=9700237
Nate Abele
@nateabele
Jun 11 2015 17:41
@CrossEye Sadly, your wisdom seems wasted on the willfully obtuse.
Also, hi everyone, I made A Thing™: https://nateabele.github.io/Powerglove/
It's still not even alpha quality, but it's the REPL I wish Ramda had.
Brandon Wilhite
@JediMindtrick
Jun 11 2015 17:48
@nateabele this thing looks sorta like another thing I've had in mind to build...do you have any kind of docs 'splainin what it is?
Nate Abele
@nateabele
Jun 11 2015 17:48
It's basically a way to make pipe()s, and see what each step is doing.
Brandon Wilhite
@JediMindtrick
Jun 11 2015 17:48
that's what I thought :)
Nate Abele
@nateabele
Jun 11 2015 17:49
It also has input tracking for map(), filter(), and sortBy(), so that if you click on one thing in one place, a highlight shows you where it comes from/goes to.
Still need to make it work for groupBy() and friends to be really useful, but the structure gets a bit complex there.
Like I said, still super early/rough, but I figured I'd post it here since y'all would probably appreciate it best. :-)
And right now the data's hard-coded into the JS, but you can play with it by cloning & replacing https://github.com/nateabele/Powerglove/blob/master/powerglove.js#L1
I'm also super proud of myself for using with() and eval() in the same line of code.
Brandon Wilhite
@JediMindtrick
Jun 11 2015 17:56
:)
so i input some kind of expression at the bottom, and it will apply that function to the hard-coded data right?
Nate Abele
@nateabele
Jun 11 2015 17:57
Yup, adds it as the next step in the pipe().
You can also click on existing steps to remove/edit them.
Right now you kinda have to clone it in order to really have any fun with it.
I'ma work on it more next week to make everything easier to mess around with though.
Brandon Wilhite
@JediMindtrick
Jun 11 2015 18:02
i might have some angular code lying around to help with the display a bit, if you're interested
maybe i'll clone yours and see what i can do
Nate Abele
@nateabele
Jun 11 2015 18:03
Of course, that'd be great.
Scott Sauyet
@CrossEye
Jun 11 2015 20:55
with and eval together? That is something to be ... proud of! :smiling_imp:
Nate Abele
@nateabele
Jun 11 2015 20:56
:shipit:
Scott Sauyet
@CrossEye
Jun 11 2015 20:56
Two great tastes that go great together!
Nate Abele
@nateabele
Jun 11 2015 20:56
^5
Nate Abele
@nateabele
Jun 11 2015 21:16
Actually, I have a question as long as I'm here.
Suppose I have a pipe(), and at the beginning of this pipe() I prop() an object hash off of each object in an array, then unroll that object such that each key/value pair is an independent object in its own array, then append the original object to the array... this is getting complicated.
Basically, I have [State] and State has an object hash called views.
And I want to end up with an array of [ [{ name: view }, state], [{ name: view }, state], [{ name: view }, state]... ]. Hopefully that's slightly less opaque than mud. :-)
Raine Virta
@raine
Jun 11 2015 21:25

@asaf-romano requested es6 support for ramda-cli. got something working now, unfortunately babel is not that quick to compile compared to LiveScript

$ echo [1,2,3] | R --es6 'map(n => n * 2)' sum
12

npm install -g ramda-cli@es6 if you want to try it

Scott Sauyet
@CrossEye
Jun 11 2015 22:35
@nateabele: Sorry, not really following. Could you give a small example of expected inputs/output?
Nate Abele
@nateabele
Jun 11 2015 23:10
@CrossEye So [{ name: "State A", views: { A: { ... }, B: { ... }, C: { ... } }] -> [[{ A: { ... }, { name: "State A", ... }], [{ B: { ... }, { name: "State A", ... }], ...]
Scott Sauyet
@CrossEye
Jun 11 2015 23:12
@nateabele: Just got my first look at Powerglove. Very nice. I can see great potential. First thing I'd like to see is to the ability to collapse at a higher level; the top level objects, and the containers that hold them.
Hardy Jones
@joneshf
Jun 11 2015 23:14
@nateabele Are the brackets are off or something?
Scott Christopher
@scott-christopher
Jun 11 2015 23:15
@nateabele perhaps something like http://bit.ly/1f5UUy5
Robert Balfre
@rob-balfre
Jun 11 2015 23:25
{ ‘428’: { lvl: 32, name: 'Emily’ }, ’399’: { lvl: 2, name: 'Alex' }, ’112’: { lvl: 2, name: 'Louise' }, ‘223’: { lvl: 40, name: 'Stuart' }, ’432’: { lvl: 9, name: 'Tina' }, ‘333’: { lvl: 15, name: 'Alex' }, ‘499’: { lvl: 5, name: 'Claire' } } Whats the functional ramda way to convert this object to an array ordered by lvl?
Nate Abele
@nateabele
Jun 11 2015 23:26
@CrossEye Filed. Feel free to make issues for anything else you think of: https://github.com/nateabele/Powerglove/issues/
@scott-christopher Looking...
@scott-christopher So for an array of states I'd map over run()?
Scott Christopher
@scott-christopher
Jun 11 2015 23:28
If you want a list of the output list, then map. If you want to combine all of the output list for each state into a single list, then chain.
Scott Sauyet
@CrossEye
Jun 11 2015 23:34
@rob-balfre: What do you want to happen to your initial keys, '428', '399', etc.? Can they just be dropped?
Robert Balfre
@rob-balfre
Jun 11 2015 23:35
@CrossEye no I’ll need them but they can be moved inside the object if need be ‘id’ would do
Scott Sauyet
@CrossEye
Jun 11 2015 23:37

Just dropping them is straightforward:

R.pipe(R.values, R.sortBy(R.prop('lvl')))

But we'd need to do something first.

Nate Abele
@nateabele
Jun 11 2015 23:38
@scott-christopher Thanks, that worked out great.
Hardy Jones
@joneshf
Jun 11 2015 23:38
toPairs then assoc and whatnot
Robert Balfre
@rob-balfre
Jun 11 2015 23:38
@CrossEye I can move the id inside in the step before, thats no prob. I’ll try out pipe. Thanks
Scott Christopher
@scott-christopher
Jun 11 2015 23:39
@rob-balfre: otherwise R.pipe(R.toPairs, R.sortBy(R.path(['1', 'lvl']))) if you want to keep the IDs
Hardy Jones
@joneshf
Jun 11 2015 23:40
@scott-christopher that's cheating ;)
Robert Balfre
@rob-balfre
Jun 11 2015 23:40
@scott-christopher thanks :)
Scott Christopher
@scott-christopher
Jun 11 2015 23:41
Everything is cheating in JavaScript :P
Robert Balfre
@rob-balfre
Jun 11 2015 23:42
Using a computer is cheating!
Nate Abele
@nateabele
Jun 11 2015 23:43
Man, these "functional" JavaScript people... they need to just stop Trine.
See what I did there? :-P
Scott Sauyet
@CrossEye
Jun 11 2015 23:47

Mine's not as pretty as the one by that other scott, but the output might be nicer:

R.pipe(R.toPairs, R.map(R.apply(R.assoc('id'))), R.sortBy(R.prop('lvl')))(data),

http://bit.ly/1L0VS8O

I love that Trine is getting so much attention. There's a hunger for better ways to work in Javascript. I personally like Ramda's way, Sanctuary's way. But I'm glad we're seeing more interesting alternatives.
Hardy Jones
@joneshf
Jun 11 2015 23:51
agreed
Nate Abele
@nateabele
Jun 11 2015 23:52
Alternatives are fine. I just wish people would stop calling everything 'functional'. Words mean things.
I think this was the quote of the day: https://news.ycombinator.com/item?id=9701018