3 ms·
Here's a challenge for you: what syntax would be better? I don't mean that in a derogatory way. I think you are right that the syntax (being very foreign to p
by mikekchar 9y ago
Here's a challenge for you: what syntax would be better? I don't mean that in a derogatory way. I think you are right that the syntax (being very foreign to people) does provide an impediment, but puzzling out how to implement the same functionality with a more familiar syntax would be extremely difficult (though potentially very fun).
- winstonewert 9y agoWell, something like C-like, for maximum familiarity. What functionality is difficult to render in C-like syntax?
- orblivion 9y agoCurrying
- winstonewert 9y agoI can get the same effect as currying with C syntax by deliberating invoking a special function: functools.partial(old_function, my_new_argument) Is this such a useful thing that you need the functional style syntax to make it even easier to do?
- nathancahill 9y agoYes
- deleted 9y ago[deleted]
- orblivion 9y agoYou can do it in Python as you have, but it becomes second nature with Haskell (I can't speak to Elm directly). You might not even realize you're doing it. Add 5 to each num in a list (using a pretend function called `add` in both languages to be fair): map(functools.partial(add, 5), nums) map (add 5) nums Add 5 to each in a list of list of numbers: map(functools.partial(map, functools.partial(add, 5)), nums) map (map (add 5)) nums
- winstonewert 9y agoI suppose it would make more sense to write these as lambdas in a c style syntax nums.map(|sublist| sublist.map(|num| add(num, 5)) Maybe I haven't done enough functional programming yet, but I still like the explicitness of the C-style over the functional style.
- kasbah 9y agoSorry, but there is nothing more explicit about using lambdas as you have done, it's simply redundant (notice the repetition of sublist and num arguments).
- crimsonalucard 9y agoRedux follows the same pattern with your more "familiar" syntax. Typed functional programming offers wins that forces more safety and modularity onto the code. These are all long term wins. Ultimately I would argue that elm's syntax is better suited for extremely complex projects that have low tolerance for bugs.
- lilactown 9y agoRedux is a javascript library. It shares some idioms with correct Elm code, but is a very different beast.
- crimsonalucard 9y agoRight but the underlying design pattern is the same. This is all I'm saying. Redux can almost be thought of as an Elm pattern implementation with "familiar" imperative syntax.