I have been reading Real World Haskell, and I am nearing the end, but a matter of style has been niggling at me to do with the (.)
and ($)
operators.
When you write a function that is a composition of other functions you write it like:
f = g . h
But when you apply something to the end of those functions I write it like this:
k = a $ b $ c $ value
But the book would write it like this:
k = a . b . c $ value
Now, to me they look functionally equivalent, they do the exact same thing in my eyes. However, the more I look, the more I see people writing their functions in the manner that the book does: compose with (.)
first and then only at the end use ($)
to append a value to evaluate the lot (nobody does it with many dollar compositions).
Is there a reason for using the books way that is much better than using all ($)
symbols? Or is there some best practice here that I am not getting? Or is it superfluous and I shouldn't be worrying about it at all?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…