|
| ▲ | raincole 3 hours ago | parent | next [-] |
| > Yes, but the exact FP idea here is that this distinction is meaningless; that curried functions are "actual results". Everyone knows that. At least everyone who would click a post titled "A case against currying." The article's author clearly knows that too. That's not the point. The point is that this distinction is very meaningful in practice, as many functions are only meant to be used in one way. It's extremely rare that you need to (printf "%d %d" foo). The extra freedom provided by currying is useful, but it should be opt-in. Just because two things are fundamentally equivalent, it doesn't mean it's useless to distinguish them. Mathematics is the art of giving the same name to different things; and engineering is the art of giving different names to the same thing depending on the context. |
| |
| ▲ | momentoftop a few seconds ago | parent | next [-] | | > It's extremely rare that you need to (printf "%d %d" foo) I write stuff like `map (printf "%d %d" m) ns` all the time. | |
| ▲ | kccqzy 2 hours ago | parent | prev [-] | | > It's extremely rare that Not when a language embraces currying fully and then you find that it’s used all the fucking time. It’s really simple as that: a language makes the currying syntax easy, and programmers use it all the time; a language disallows currying or makes the currying syntax unwieldy, and programmers avoid it. |
|
|
| ▲ | jstanley 2 hours ago | parent | prev | next [-] |
| If 0 and a function that always returns 0 are the same thing, does that make `lambda: lambda: 0` also the same? I suppose it must do, otherwise `0` and `lambda: 0` were not truly the same. |
| |
| ▲ | fn-mote 2 hours ago | parent [-] | | Another way to make the point: when you write 0, which do you mean? In a pure language like Haskell,
0-ary functions <==> constants |
|
|
| ▲ | AnimalMuppet 3 hours ago | parent | prev | next [-] |
| Fine, it's a regular type. It's still not the type I think it is. If it's an Int -> Int when I think it's an Int, that's still a problem, no matter how much Int -> Int is an "actual result". |
| |
| ▲ | kccqzy 2 hours ago | parent [-] | | Come on, just write let f :: Int = foobinade a b
And the compiler immediately tells you that you are wrong: your type annotation does not unify with compiler’s inferred type.And if you think this is verbose, well many traditional imperative languages like C have no type deduction and you will need to provide a type for every variable anyways. | | |
| ▲ | AnimalMuppet 2 hours ago | parent [-] | | I spent the last three years on the receiving end of mass quantities of code written by people who knew what they were writing but didn't do an adequate job of communicate it to readers who didn't already know everything. What you say is true. And it works, if you're the author and are having trouble keeping it all straight. It doesn't work if the author didn't do it and you are the reader, though. And that's the more common case, for two reasons. First, code is read more often than it's written. Second, when you're the author, you probably already have it in your head how many parameters foobinade takes when you call it, but when you're the reader, you have to go consult the definition to find out. But if I was willing to do it, I could go through and annotate the variables like that, and have the compiler tell me everything I got wrong. It would be tedious, but I could do it. |
|
|
|
| ▲ | skywhopper 2 hours ago | parent | prev [-] |
| It’s not at all clear or the same to the new reader of the code. |