These are chat archives for ramda/ramda

3rd
Jun 2015
James Forbes
@JAForbes
Jun 03 2015 03:06

Funny how some popular functional programming function names can sound so imperative. compose and partial are both stating "how" they are going to create some new function. Whereas declarative function names would describe what the intent is.

Perhaps if compose was called sequence and partial was called prepare (or some other names, that indicate "what" as opposed to "how" ), we'd see a lot more people using composition instead of chaining, and a lot less anonymous callbacks.

I guess in a sense the distinction is not so simple. But there is a continuum of "what" "how". I think compose, partial are closer to the "how" than the "what".

And curry is such an opaque name. It falls in the Boolean camp for me. It is not even on the "what-how" continuum, it is on the "who? when?" continuum. It should be called a lazyor a patient function, or some other declarative descriptive name.

I'm not really bothered by the names, because I am used to them. But it just struck me as odd considering fp's advocacy for being declarative.

Hardy Jones
@joneshf
Jun 03 2015 03:17
I think that depends on your internal connotations for those words
James Forbes
@JAForbes
Jun 03 2015 03:47

Connotations are exactly right. And everyone has different connotations. But if I see g = partial( f, a,b,c)I am being told, I'm creating a function g.

"how" am I creating it? via partial application. Which is imperative.

If I saw g = prepare(f, a,b,c) I am being told again that I am creating function g. "what" is g? It is f with some argument prepared for me. How are they prepared? - not important, we are being declarative.

And maybe you could say partial is declarative in the sense that there are many ways to implement partial application behind the scenes. But the intent is not to partially apply, the intent is to create some new functionality in g based on f.
Ironically class extends baseClass is more declarative than g = _.partial(f, ...)
Hardy Jones
@joneshf
Jun 03 2015 04:01

I dunno, that seems pretty hair splitty to me. You could put those same words in different sentences and have it sound different:

...if I see g = prepare( f, a,b,c) I am being told, I'm creating a function g. "how" am I creating it? via preparation. Which is imperative...
...If I saw g = partial(f, a,b,c) I am being told again that I am creating function g. "what" is g? It is f with some argument partially applied for me. How are they partially applied? - not important, we are being declarative...

James Forbes
@JAForbes
Jun 03 2015 05:10

I see your point.

Say we have a blender function. And we want a banana smoothie function.

bananaSmoothie = prepare( blender, bananas, other, ingredients)
bananaSmoothie = partial( blender, bananas, other, ingredients)

Would you say that in this case, creating a bananaSmoothie function via either means, is equally declarative/imperative. And it is just a case of connotations?
Is it just semantics?

I see partialas describing an implementation detail, not an abstraction. Whereas prepare is an abstraction but does not describe the underlying mechanics.
partial is not as imperative as a for loop (specifying exactly how we are going to iterate over a given datatype), but is still specifying a particular strategy (partial application).

Hardy Jones
@joneshf
Jun 03 2015 05:24
I tend to believe that a word in a program has exactly zero relation to the English connotation of the same word.
Tobias Pflug
@gilligan
Jun 03 2015 05:47
it should not - or rather you should not rely on your intuition what the word means to you because it might not reflect what it actually does
hence types - in sane languages
;}
Simon Friis Vindum
@paldepind
Jun 03 2015 06:24
@JAForbes I don't understand your meaning of declarative. But it sounds to me like "has to sound like normal English" is a part of it. That makes no sense to me. The way I understand it when you write g = partial(f, a, b, c) it's declarative because of the equal sign. You declare that g is f partially applied to a, b and c. Whatever you call partial does not matter. Both of your bananaSmoothie declarations are declarative to me exactly because they're declarations. Giving a step by step recipe on how to create a banana smoothie would have been imperative.
Simon Friis Vindum
@paldepind
Jun 03 2015 07:11
@gilligan Wierd. I'm using vim and tern as well and I haven't had any issues.
Tobias Pflug
@gilligan
Jun 03 2015 07:28
@paldepind it is quite possible that it is something specific that makes tern go nuts - I have been using it a while as well and only recently got problems
Raine Virta
@raine
Jun 03 2015 07:58
what's the most useful feature in tern+vim, smart autocomplete?
I used to have the tern plugin in its early days but it was very resource hoggy
Tobias Pflug
@gilligan
Jun 03 2015 08:03
that plus its type inference
Tobias Pflug
@gilligan
Jun 03 2015 08:14
dear smart people in this channel : i am sure this can be done in a shorter more concise way ? any suggestions ? http://lpaste.net/133810
Raine Virta
@raine
Jun 03 2015 08:38
var {max, map, strIndexOf, __, substringFrom} = require('ramda');

var maxPos = (str, xs) => max(map(strIndexOf(__, str), xs));
var stripPath = (path, names) => substringFrom(maxPos(path, names), path);
Tobias Pflug
@gilligan
Jun 03 2015 08:57
@raine :-)
Brandon Wilhite
@JediMindtrick
Jun 03 2015 12:15
I tend to side with @JAForbes , I don't think you can separate connotation from denotation (after all, we're human)...this is why we have such emphasis on trying to name things well. Otherwise we could (should?) just name things with a bunch of letters and symbols. Then again, maybe that's why a lot of the more "pure" functional approaches tend to do exactly that ;) So maybe it's a continuum, after all.
On a related note...I've been wondering whether this is true:
Functor, Monad (and some friends) are nouns
compse, add, find (and friends) are verbs
Is that right?
Simon Friis Vindum
@paldepind
Jun 03 2015 12:37
@raine treis is awesome! And the vim mappings are just icing on the cake. Have you considered using R.toString?
David Chambers
@davidchambers
Jun 03 2015 17:56
@paldepind, I like your proposal for type checking arguments. I’m going to try this approach in Sanctuary.
Simon Friis Vindum
@paldepind
Jun 03 2015 18:22
@davidchambers Nice! I'm excited to see how it goes.
Stefano Vozza
@svozza
Jun 03 2015 19:05
Oh that could be very nice.
Raine Virta
@raine
Jun 03 2015 19:36
paldepind: i'm glad you find it useful. do you mean using R.toString to format the output?
David Chambers
@davidchambers
Jun 03 2015 21:10
I hadn’t thought of map as lift1, @CrossEye. Thanks for the aha moment!
Michael Hurley
@buzzdecafe
Jun 03 2015 22:58
aha 2: lift2 ~ zip