3 ms·
Seems to me that using the functional style it's really important to document the types (done in the article with the //+ lines). Otherwise it will be hard to
by platz 13y ago
Seems to me that using the functional style it's really important to document the types (done in the article with the //+ lines).
Otherwise it will be hard to make the types line up.
Also there are functions in javascript which do different things depending on what the type of the argument is (or do different things depending on how many arguments are passed in; those kinds of functions always have irked me), so it would be hard to document exactly what the "type" of those functions are.
- lrichardson 13y ago@platz, yes, this is correct. When currying and/or composing functions, it becomes more difficult to determine the input/output types of the function since the function signature won't be right there. I'm borrowing the `//+` syntax from Brian Lansdorf, since I saw him use it and quite like it. He mentioned he has "a lot to say on the topic" of commenting / type sigs, but I haven't heard him speak specifically on that. Also, for functions that do different things depending on how many arguments are passed in, you would never want to curry these. The curry function relies on the function passed in expecting a specific number of arguments.
- platz 13y agoPart of me thinks that if you're going to pursue this style to it's extreme, you might as well just be better off using something like purescript http://purescript.readthedocs.org/en/latest/intro.html#hello-purescript http://purescript.readthedocs.org/en/latest/intro.html#hello...
- lrichardson 13y agoI haven't had a chance to try purescript yet, but I have looked at it. Really though, I love JavaScript, and don't have much desire to use another language that that transpiles into it...
- platz 13y agoFair enough, there's always headaches with transpilers; I for one have been suspicious of all the coffeescript+derivatives.