These are chat archives for ramda/ramda

9th
Feb 2016
joneshf-work1
@joneshf-work1
Feb 09 2016 00:00
@boxofrox what are you trying to do?
David Chambers
@davidchambers
Feb 09 2016 00:07
I'm not really in a position to review that pull request, @gilligan. It's all new to me.
Tobias Pflug
@gilligan
Feb 09 2016 00:07
@davidchambers yeah i'm afraid that applies for most of us
@davidchambers I am interested in how this affects Ramda (like i tried to point out several times in the discussion). I'm afraid i might just be off topic with that on the PR
David Chambers
@davidchambers
Feb 09 2016 00:09
I think the existing lens functions should remain in Ramda.
Tobias Pflug
@gilligan
Feb 09 2016 00:10
@davidchambers just as-is or through an added ramda-lens dependency ?
David Chambers
@davidchambers
Feb 09 2016 00:12
So far we've said no to dependencies, so as is, I imagine.
Tobias Pflug
@gilligan
Feb 09 2016 00:13
I see. I was under the impression that ramda-lens was created to move the lens stuff out of ramda
but maybe i just got that wrong - that would also mean that the concerns i brought up in the PR are quite irrelevant
David Chambers
@davidchambers
Feb 09 2016 00:14
Removing the lens-related functions from Ramda is an option. My view is likely one of several.
I'm on the other side of the fence, though. I'd like to see some of the non-lens functions removed, as we have a dozen or so functions which duplicate the functionality of lens-related functions.
Tobias Pflug
@gilligan
Feb 09 2016 00:15
I guess I am the victim of my own egoistic perspective - which is I would love to have some of the extended functionality that can be had with iso and prisms and what not - but i might have a hard time convincing people to add ramda-lens to our codebase when I can't explain most of it myself even
David Chambers
@davidchambers
Feb 09 2016 00:16
That doesn't sound egotistical. Pragmatic, I would say.
Tobias Pflug
@gilligan
Feb 09 2016 00:16
pragmatic, yes
from a pragmatical standpoint i would even say: I could imagine to integrate master of ramda-lens into Ramda - and get rid of some of the functions that overlap in functionality like you said
the same would not apply for the profunctor branch because it's just rather huge in comparison
Jethro Larson
@jethrolarson
Feb 09 2016 03:37
Ramda 2.0 with standard type scheme and lenses like daaaamn. I'd sign up for that
boxofrox
@boxofrox
Feb 09 2016 13:33
@joneshf-work1 I was mostly curious if there was an alternative to R.converge(Array.of, []) I may have overlooked. ultimately, i'm collecting statistics from a database. for any given day and product sku, I can review how many were bought/sold in the past week, month, quarter, year. That snippet above is seeding the database table and only runs once.
Keith Alexander
@kwijibo
Feb 09 2016 14:13
is there a name for the patterns R.converge(f, [identity, g]) and R.converge(f, [g,identity])?
Martin Broder
@mrtnbroder
Feb 09 2016 16:22
is there a a way to teach R.contains to accept an array of possible values?
e.g. R.contains([1, 2], [1,2,3,4,5,6])
Denis Stoyanov
@xgrommx
Feb 09 2016 16:23
@mrtnbroder why not diff?
Martin Broder
@mrtnbroder
Feb 09 2016 16:24
because there are 21313 functions within ramda and I don't know all of them @xgrommx :P
thanks!
Raine Virta
@raine
Feb 09 2016 16:24
intersection?
Denis Stoyanov
@xgrommx
Feb 09 2016 16:25
or intersection
Raine Virta
@raine
Feb 09 2016 16:34
some activity after a while in ramda-cli, added https://github.com/raine/ramda-cli#-d---pretty-depth
kwijibo @kwijibo wonders if an Elixir style grouping of functions would make Ramda's API easier to hold in one's head
Keith Alexander
@kwijibo
Feb 09 2016 16:35
eg R.List.filter(func, list)
R.String.toUpper
Raine Virta
@raine
Feb 09 2016 16:37
filter is not just used for Lists, but anything that has .filter method
Tomi Pieski
@tomipieski
Feb 09 2016 16:37
How can one transform [{"x": "a", "y": "b"},{"x": "c", "y": "d"},...] into [{"x":["a","c"],"y":["b","d"],...}] with ramda?
Raine Virta
@raine
Feb 09 2016 16:38
@kwijibo and then you'd have to hold in your head which group a function belongs to
Keith Alexander
@kwijibo
Feb 09 2016 16:41
@raine yeah, mapping ramda functions to, even made-up types, is pretty tricky
Raine Virta
@raine
Feb 09 2016 16:42
and finally, destructuring would be pain:
const R = require('ramda')
const { toUpper } = R.String
const { map } = R.List
so maybe only as extension of ramda
Brian Gates
@brian-gates
Feb 09 2016 17:40
{ foo: { id: 1 }, bar: { id: 2 } } --> [1,2]. What's the best way to do this?
mostly just want an ability to unnest object keys
oh, R.values
I think that's the piece I needed
Aldwin Vlasblom
@Avaq
Feb 09 2016 17:43
@brian-gates I believe this example is in the cookbook. :smile:
Oh, never mind. I misread your datastructure.
Brian Gates
@brian-gates
Feb 09 2016 17:44
Not quite... yeah :)
but that's also helpful
R.pipe(R.values, R.path(['id'])) does what I want
more or less
I think a flatten is required in there, but the gist is there. R.values was exactly what I needed.
Tomi Pieski
@tomipieski
Feb 09 2016 17:49
@raine how to get mergeWith working in R.pipe or R.compose? I got grouping and R.project producing almost what I want:
var qaTable = R.pipe(
  R.groupBy(R.prop('name')),
  R.map(R.project(['x', 'y']))
)
I've just begun experimenting with ramda :)
Brad Compton (he/him)
@Bradcomp
Feb 09 2016 18:06
@brian-gates Try this:
var inp = { foo: { id: 1 }, bar: { id: 2 } }

var getIds = R.compose(R.values, R.map(R.prop('id')))

getIds(inp)
Raine Virta
@raine
Feb 09 2016 18:07
also map(prop('id')) is pluck('id')
Brian Gates
@brian-gates
Feb 09 2016 19:16
yeah that's what I ended up doing, @Bradcomp :)
good to know about pluck, too.
is there an existing shorthand for R.compose(R.flatten, R.of)?
flatten might be overkill. the point being to ensure array-ness of a provided value.
Brad Compton (he/him)
@Bradcomp
Feb 09 2016 19:18
Funny, I have a toArray function that is exactly that.
Brian Gates
@brian-gates
Feb 09 2016 19:19
just want to make sure I'm not reinventing an existing wheel :)
seems like something that would exist, but perhaps not.
Raine Virta
@raine
Feb 09 2016 19:29
maybe this is more readable ifElse(is(Array), identity, of)
Brian Gates
@brian-gates
Feb 09 2016 20:00

meanwhile, this is literally in their docs:

http://ramdajs.com/docs/#unless

// coerceArray :: (a|[a]) -> [a]
var coerceArray = R.unless(R.isArrayLike, R.of);
coerceArray([1, 2, 3]); //=> [1, 2, 3]
coerceArray(1);         //=> [1]
lol
Raine Virta
@raine
Feb 09 2016 20:01
nice
Brian Gates
@brian-gates
Feb 09 2016 20:01
although my behavior is slightly different in that it guarantees a flat array