4 ms·
It's just new and you're not used to it. There's nothing wrong with finding new and different syntax confusing, as long as you're willing to keep an open mind.
by tikhonj 13y ago
It's just new and you're not used to it. There's nothing wrong with finding new and different syntax confusing, as long as you're willing to keep an open mind.
If you use it for a while, you'll get used to it. After a while, I've found it makes the most sense. I think it's better because it reduces the amount of syntactic noise in the code.
It's a simple design decision. Function application is the most important part of the language. So it gets the best syntax: none.
- jessedhillon 13y agoCan you give an example of composed function application? E.g., f(a, b, g(x, y)) Thanks
- seliopou 13y agof a b (g x y)
- tikhonj 13y agoYou use parentheses only for grouping. So f a b (g x y) is how you would write your example. In Elm, you could also use the function application operator to avoid writing the parentheses: f a b <| g x y -- EDIT: flipped the operator around In Haskell, this would be done with $, which used to exist in Elm as well: f a b $ g x y Once you get used to mentally parsing the $ as grouping the rest of the expression together--admittedly, it does take a little while--the last version is probably the most readable. At least that's what I've found.
- quarterto 13y agoThe |> looks weird to me. It's the opposite way around to F# (and thus LiveScript). Is that really equivalent to Haskell's $?
- wheatBread 13y agoSmall revision, the second code line should be: f a b <| g x y Just like F# :)
- weavie 13y agoF# could also write that as g x y |> f a b. Which can read much more intuitively - you are sending the results of g x y to the function f a b. (I think its that, I'm a little rusty..)