TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Omg-Curry – JavaScript currying library

11 pointsby debdutalmost 5 years ago

6 comments

ufoalmost 5 years ago
I had mixed results in the past when I tried to use currying in Javascript. The stack traces were cluttered by references to the currying function and it also masked bugs if you forgot to pass an argument. Without currying, if you pass less arguments than the function expects then you usually get an error right away complaining that the argument is undefined. However, if the function is curried then it silently succeeds. You only notice the problem later, when you try to use the return value and realize that it is actually a function. To make things worse, when this happens the stack trace points to the place that is trying to use the return value instead of pointing to the function call that is the actual source of the problem.<p>My final impression was that currying works better a language like Haskell that has a strong type system. In a dynamic language it is more problematic.
评论 #24117826 未加载
brundolfalmost 5 years ago
JavaScript actually has a pretty ergonomic way of doing currying natively:<p><pre><code> const add = (a) =&gt; (b) =&gt; a + b; [1, 2, 3, 4].map(add(2)); &#x2F;&#x2F; [3, 4, 5, 6]</code></pre>
评论 #24115100 未加载
gitgudalmost 5 years ago
Sorry I&#x27;m not that familiar with this. What would be a good use-case for currying?<p>The example doesn&#x27;t feel that exciting...<p><pre><code> add4(1)(3)(5)(10) add4(1)(3,5)(10) add4(1,3,5,10) &#x2F;&#x2F; 19</code></pre>
评论 #24116871 未加载
评论 #24117319 未加载
评论 #24115352 未加载
giancarlostoroalmost 5 years ago
&gt; WTF is Curry?<p>&gt; A Curry takes arguments one by one unlike functions which takes all arguments at once.<p>Took the words right out of my brain.
finnhalmost 5 years ago
The old &quot;drop a link&quot; routine isn&#x27;t beloved here at HN, but this xkcd is just so good:<p><a href="https:&#x2F;&#x2F;xkcd.com&#x2F;2210&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;2210&#x2F;</a>
randompwdalmost 5 years ago
funny how most react devs were using currying directly when they were calling redux lib.<p>still think it(redux) was a misplaced usage of currying.