4 ms·
It's accessible to anybody with any experience programming and who is willing to pay attention. You are just taking a formula out of context, omitting the plain
by qsort 3y ago
It's accessible to anybody with any experience programming and who is willing to pay attention. You are just taking a formula out of context, omitting the plain English explanation that comes before it, and pretending it's some kind of alien math. It's not scary at all, in fact it's very simple.
Let's do this in Python. First, write a function that curries:
def curry(f):
def g(x):
def h(y):
return f(x, y)
return h
return g
my_func = lambda x, y: 10 * x + y
curried = curry(my_func)
print(curried(5)(3))
# output: 53
Now, let's type it in such a way that mypy --strict won't complain:
from typing import TypeVar, Callable
A = TypeVar('A')
B = TypeVar('B')
C = TypeVar('C')
def curry(f: Callable[[A, B], C]) -> Callable[[A], Callable[[B], C]]:
def g(x: A) -> Callable[[B], C]:
def h(y: B) -> C:
return f(x, y)
return h
return g
What's the type of curry? Let's hover our cursor over the function name, and lo and behold:
Callable[[Callable[[A, B], C]], Callable[[A], Callable[[B], C]]]
That's it. That's all it's saying.
- _a_a_a_ 3y ago> You are just taking a formula out of context, omitting the plain English explanation that comes before it, which, this? "We saw earlier in the course that we can curry a function. That is, given a function of type (τ 1 ×τ 2 ) → τ 3 , we can give a function of type τ 1 → τ 2 → τ 3" That helps no-one unless you have some serious hand-holding. I know the type of curry, I've written curry/bind/whateveer in C#, scala, JS and likely others. I have a background in this. It's not 'accessible' to mere mortals and even I'm not familiar with some of the notation here. Stop pretending it's just laziness on other people's part. (oh yeah, did I forget to put constructive logic in my list above? Brouwer's intuitionism? FFS get real, I never even heard of that until a few years ago)
- zozbot234 3y agoIt is accessible if you know a few bits of syntax, such as → being right-associative so τ1 → τ2 → τ3 means τ1 → (τ2 → τ3). And others such as "f: X → Y declares f as a function from X's to Y's." which you can find in any math textbook. The point of using such a terse notation rather than faffing around with Callable[…] is to make it possible to work with larger examples without getting bogged down in the verbiage. It's why we use symbols to solve equations in K-12 math.
- _a_a_a_ 3y agoThe curse of intelligent people, the one thing they can't understand; never being able to understand that other people don't understand. There's something of Cassandra about it.
- sordina 3y agoIf someone can learn C type syntax this is MUCH simpler. That doesn't mean you don't have to spend a little bit of time learning how it works, but it is not some kind of number-theory level maths construction only accessible to savants.
- _a_a_a_ 3y agoSee my reply https://news.ycombinator.com/item?id=37855705 https://news.ycombinator.com/item?id=37855705
- automatoney 3y agoThis would be a really good (and much more accessible than the linked pdf) explanation without the condescending tone. This is some pretty advanced math, and pretending otherwise isn't constructive. If someone says "I'm having trouble understanding this", it's not their fault, and it's generally not laziness - it just means that the explanation isn't suited to them.
- vilhelm_s 3y agoIt's not any kind of advanced math at all! The quoted fragment above is just a line of computer code. Anyone who has done any programming in any typed language should be easily able to understand it, though they may need to look up the syntax.
- AnimalMuppet 3y agoNope, not me. But I've only been programming for 40 years, so maybe I'll get it when I've got more experience. In other words, baloney. If you don't do that kind of programming, that stuff is very opaque. I might be able to get it if I were willing to stare at it for another 15 minutes, but I'm not willing.
- rsrsrs86 3y agoBy trying to look smart you look stupid in assuming this is simple. You need to improve your soft skills.