New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Would be great to see a 'Why?' section for each entry #76
Comments
That's a great question but one that's better served by a blog article than a glossary. I remember this being a decent explanation http://fr.umio.us/favoring-curry |
Maybe this is a good candidate for the wiki? |
Thanks for that link @jethrolarson - nice explanation. Maybe each entry could have a 'Read More' section, with links to further reading, Wikipedia articles, blogs, the Wiki here, etc...? |
Yeah, maybe if we can keep it curated and not overwhelming On Tue, Jul 26, 2016, 9:13 AM Duncan Lock notifications@github.com wrote:
|
Your response inspired me to add a link to the article to the curry section |
To be honest, I was asking the same question as the OP for a long time until I read that article. I think a lot of confusion about currying can be attributed to being too conditioned to imperative languages. A C or JavaScript programmer is probably inclined to see a function as any grouped set of instructions, whereas in purely-functional programming languages, things are built quite differently... It's all about engaging with a whole new mindset, which is I've grown so interested in functional programming (and top kudos to this repo, SERIOUSLY). I'm too damn used to JavaScript, hahaha. |
BTW, here's a practical use for currying in JavaScript I wrote. =) /**
* Curried method to append multiple nodes at once.
*
* @example addTo(node)(el1, el2, …)
* @example node = addTo(node)(…)[0]
* @return {Function}
*/
function addTo(parent){
let count = 0;
let target = parent;
const fn = (...nodes) => {
let lastElement;
for(let node of nodes){
if("string" === typeof node)
node = document.createTextNode(node);
else
lastElement =
fn[++count] = node;
target.appendChild(node);
}
target = lastElement || target;
return fn;
};
fn[count] = target;
return fn;
} So to produce the following HTML... <header id="top">
<h1>
<a class="permalink" href="#top">
Heading
</a>
</h1>
</header> ... you'd use: addTo(document.body)
(New("header", {id: "top"}))
(New("h1"))
(New("a", {className: "permalink", href: "#top"}))
("Heading"); (This example uses my beloved Hope this helps somebody! Let me know if my curry-cooking sucks! |
I think we should address the "Why" via links either to the wiki or to external resources. We've done that for curry and a couple others. Ensuring that every term has a approachable "why" would be quite the undertaking so I think we should address those in individual issues/PRs. We could track this as an initiative and tag the issues/PRs with a "Why" tag. Either way I think this issue is a little too open ended to be left open indefinitely. If there are specific terms that you really want to see a motivation for feel free to open a issue specific to that term. |
Hey @jethrolarson, I'm still waiting for you to answer. =) |
Ok, so you've explained... currying or functors. Great. But why would I want to curry a function? What's the benefit of doing that? How is it used in the real world?
The text was updated successfully, but these errors were encountered: