Skip to content
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

Closed
dflock opened this issue Jul 26, 2016 · 10 comments
Closed

Would be great to see a 'Why?' section for each entry #76

dflock opened this issue Jul 26, 2016 · 10 comments

Comments

@dflock
Copy link

dflock commented Jul 26, 2016

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?

@jethrolarson
Copy link
Collaborator

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

@hemanth
Copy link
Owner

hemanth commented Jul 26, 2016

Maybe this is a good candidate for the wiki?

@dflock dflock changed the title Would be great to see a Why? sectio Would be great to see a Why? section Jul 26, 2016
@dflock dflock changed the title Would be great to see a Why? section Would be great to see a Why? section for each entry Jul 26, 2016
@dflock dflock changed the title Would be great to see a Why? section for each entry Would be great to see a 'Why?' section for each entry Jul 26, 2016
@dflock
Copy link
Author

dflock commented Jul 26, 2016

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...?

@jethrolarson
Copy link
Collaborator

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:

Thanks for that link @jethrolarson https://github.com/jethrolarson -
nice explanation.

Maybe each entry could have a 'Read More' section, with links to further
reading, Wikipedia articles, blogs, the Wiki here, etc...?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#76 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAB-4KP4mEfIp8nPZADF23gjRx8JkGI2ks5qZjIDgaJpZM4JU4jn
.

@Alhadis
Copy link

Alhadis commented Aug 14, 2016

But a curried version behaves more usefully:

formatName1("John", "Paul");
//=> "John Paul undefined");
formatName1("John", "Paul")("Jones");
//=> "John Paul Jones"

E P I P H A N Y

@jethrolarson
Copy link
Collaborator

Your response inspired me to add a link to the article to the curry section

@Alhadis
Copy link

Alhadis commented Aug 18, 2016

12687866_924665384298430_4879727175629932168_n

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.

@Alhadis
Copy link

Alhadis commented Aug 26, 2016

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 New function to generate HTML elements easily).

Hope this helps somebody! Let me know if my curry-cooking sucks!

@jethrolarson
Copy link
Collaborator

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.

@Alhadis
Copy link

Alhadis commented Nov 5, 2016

Hey @jethrolarson, I'm still waiting for you to answer. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants