3 ms·
You 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
by tikhonj 13y ago
You 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..)