These are chat archives for ramda/ramda

11th
Feb 2016
James Forbes
@JAForbes
Feb 11 2016 07:55 UTC

After reading about Maybe, and watching Railway Oriented Programming I'm seeing NaN in a whole different light.

NaN * 50 == NaN is kind of like Maybe(Number) * 50. In the broadest sense. It doesn't thrown an error. Its not a very precise comparison, but it struck me as interesting.

Jethro Larson
@jethrolarson
Feb 11 2016 08:16 UTC
Totes. I still need to build a larger application with Maybes to see how fun it is after the honeymoon is over
Tobias Pflug
@gilligan
Feb 11 2016 09:02 UTC
man now I really need prisms in Ramda ;/
a pragmatic approach
Keith Alexander
@kwijibo
Feb 11 2016 09:29 UTC
Wow. there are 231 functions in Ramda
No wonder most of the questions in here are "is there a shorter way to write this in Ramda?"
GÁBOR Áron Zsolt
@ashnur
Feb 11 2016 11:30 UTC
nah, there is no way you could call ramda bloated, so it's ok
it has a very clear scope and all :D
Keith Alexander
@kwijibo
Feb 11 2016 11:40 UTC
Dunno, large number of top level functions, impossible to remember them all, kinda reminds me of PHP
I think it's a possible area of improvement; if not in the API, at least in the documentation, how to make such a large number of functions more tractable, learnable, and less intimidating for newcomers
Raine Virta
@raine
Feb 11 2016 11:42 UTC
you don't have to remember them all, that's why you have API documentation, and through experience you develop intuition on what parts of your code can be improved because you see room for generalization for example
Keith Alexander
@kwijibo
Feb 11 2016 11:54 UTC
You don't HAVE to remember them all, but the more you can hold in your head, the more productive you can be
And of course it helps if you can easily get a feel for what's available when you skim the docs
Tobias Pflug
@gilligan
Feb 11 2016 12:18 UTC
you can always create a PR to remove functions you feel are not needed
Keith Alexander
@kwijibo
Feb 11 2016 12:30 UTC
nah, it's not that I would want to remove any functions in particular
just wondering what ways, if any, could help users find/understand them when there are so many
Keith Alexander
@kwijibo
Feb 11 2016 16:28 UTC
@JAForbes that's interesting, the NaN swallows any other numeric operations you try to do with it, and always returns NaN
same with Infinity
but if you try to do a string operation, the string container swallows the other object
James Forbes
@JAForbes
Feb 11 2016 16:43 UTC
well from the perspective of the string operation, NaN is a valid value. Which is interesting, who decides the validity of a value, the object or the subject?
Keith Alexander
@kwijibo
Feb 11 2016 16:46 UTC
it doesn't matter who is the subject or object, it works in a hierarchy of types doesn't it?
James Forbes
@JAForbes
Feb 11 2016 17:06 UTC

Oh I meant, from String's perspective, NaN is a valid subject. But NaN's perspective it is an invalid Number.

The string consuming it is the object choosing the validity of the subject, but imagine if NaN could retain its invalidity after a String(NaN), then the subject would be deciding its own invalidity, which reminds me of dispatching to a types internal map implementation

That probably makes no sense, I apoligise
Keith Alexander
@kwijibo
Feb 11 2016 17:11 UTC
ah ok, I see what you mean... I think :)
James Forbes
@JAForbes
Feb 11 2016 17:12 UTC
:)
Keith Alexander
@kwijibo
Feb 11 2016 17:13 UTC
does anyone have experience with daggy or @paldepind's union-type library, or any others out there?
Francisco Ryan Tolmasky I
@tolmasky
Feb 11 2016 21:10 UTC
is there a way to turn x => f(x) into x => mixin(x, "y', f(x.y)), so like on(f, "y")(x)
Keith Alexander
@kwijibo
Feb 11 2016 21:33 UTC
what does the "y" mean? a string?
what's mixin ?
Francisco Ryan Tolmasky I
@tolmasky
Feb 11 2016 21:35 UTC
sorry I'm using 0.9.1 terminology
R.mixin
I don't know what its called now
but this is what I'm doing right now:
function on(aProperty, aFunction)
{
return function(anObject)
{
return R.assoc(aProperty, aFunction(R.prop(aProperty)(anObject)), anObject);
}
}
Keith Alexander
@kwijibo
Feb 11 2016 21:58 UTC
@tolmasky do you want to set the property of an object to the output of a function over the value?
if so R.over(R.lensProp('y'),f)(x) might be what you're looking for?
Jack Firth
@jackfirth
Feb 11 2016 22:29 UTC
filter works for any Filterable, but how can I get a filterIndexed function that works for any Filterable that has indexes? Is there some notion of Indexable in Ramda?
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 22:40 UTC
looking for some help regarding curry and/or compose
I'm basically composing (find, path)
but would like it to be curried
afaik, most Ramda functions are automatically curried, but this doesn't seem to be the case with compose
should I "not" use compose in this case, and simply use a function expecting 2 arguments?
thx :)
Raine Virta
@raine
Feb 11 2016 22:42 UTC
SebastienDaniel: example would be good
David Chambers
@davidchambers
Feb 11 2016 22:43 UTC
@jackfirth, there's currently no notion of something which is indexable.
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 22:44 UTC
compose(find(fn), path(p));
and I'll be providing an array to the composed function.
However, I'd like to call it as:
(["this", "is", "a", "path"])((x) => !!x)(data)
instead of providing all 3 arguments at once
ahh nvm
Brad Compton (he/him)
@Bradcomp
Feb 11 2016 22:46 UTC
is ((x) => !!x) the function you would like to use in find
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 22:46 UTC
no no, it was just for a simplified example
I think I just groked when to curry and when to compose :P
David Chambers
@davidchambers
Feb 11 2016 22:46 UTC
x => !!x is better written Boolean, by the way. ;)
Jack Firth
@jackfirth
Feb 11 2016 22:46 UTC
@davidchambers If I want something that filters objects by key and value and arrays by index and value, is there a simpler way to do that than writing it myself?
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 22:47 UTC
@davidchambers thx
if I understand properly, I would curry functions that I would later want to compose. correct?
well, functions with arity > 1
and... dumb question... I should curry a compose ?
shouldn't**
David Chambers
@davidchambers
Feb 11 2016 22:48 UTC
@jackfirth, you could write a function that operates on pairs, then write a function to get from ['foo', 'bar', 'baz'] to [[0, 'foo'], [1, 'bar'], [2, 'baz']] (and use R.toPairs to get from StrMap a to Pair String a).
Jack Firth
@jackfirth
Feb 11 2016 22:49 UTC
@davidchambers literally just finished writing that in the ramda repl...
David Chambers
@davidchambers
Feb 11 2016 22:49 UTC
:)
Brad Compton (he/him)
@Bradcomp
Feb 11 2016 22:50 UTC
From my understanding, compose returns a non-curried function.
David Chambers
@davidchambers
Feb 11 2016 22:50 UTC
@SebastienDaniel, currying and composition are usually separate concerns. When currying a binary function, though, whether or not the function is curried can be significant.
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 22:52 UTC
gotcha
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 23:17 UTC
wow
var select = R.curry(function(p, w, d) {
return R.find(R.whereEq(w))(R.path(p, d));
});
I love this thing
any performance gotchas I might need to be aware of?
I'm especially suspicious of whereEq()
David Chambers
@davidchambers
Feb 11 2016 23:19 UTC
I suggest not worrying about performance until you actually have a performance issue.
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 23:19 UTC
classic :P
but alright, I'll listen to that and give it a shot
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 23:26 UTC
@davidchambers I just realized you're one of the main contributors. Great work on Ramda, btw! I was curious what got you so passionate about functional programming.
David Chambers
@davidchambers
Feb 11 2016 23:28 UTC
There were several factors. I found Rich Hickey's talks very compelling. I worked with some people who were interested in functional data structures. I'd experienced the problems caused by mutable state. Plus, functional programming is a lot of fun!
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 23:30 UTC
Yeah, mutable state gave me quite a few headaches. I dove into Redux and Immutable and finally wound up here :)
David Chambers
@davidchambers
Feb 11 2016 23:33 UTC
Welcome!
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 23:37 UTC
thx!
Sebastien Daniel
@SebastienDaniel
Feb 11 2016 23:58 UTC
is the youtube channle ClojureTV where you found his talks?