<div dir="ltr">Hi folks, <div><br></div><div>Haskell beginner here. I ran across the expression below (from the <a href="http://www.haskellbook.com">Haskell Programming From First Principles</a> book), and I was having a hard time putting parenthesis around the expression in order to make the order of application more explicit. </div><div><br></div><div>Here is the expression in question: <b>take 5 . filter odd . enumFrom $ 3</b></div><div><b><br></b></div><div>I realize that part of the hang-up that I was having was that I focused solely on the fact that function application is left-associative, and not on the fact that specific functions / operators can have a declared precedence. Once I realized that the $ operator has a declared precedence of 0, the expression took on the following form:</div><div><br></div><div><b>(take 5 . filter odd . enumFrom) $ (3)</b></div><div><b><br></b></div><div>Now, everything to the left of the $ operator is simply function application (whitespace) and the function composition operator. I made the same mistake again of ignoring the fact that particular functions / operators can have a declared precedence. Realizing that mistake, and that the function composition has a declared precedence of 9, then the expression took on this form:<br></div><div><br></div><div><b>((take 5) . (filter odd) . (enumFrom)) $ (3)</b></div><div><b><br></b></div><div>So, the general rule that I took away from this is that, when trying to imagine how an expression reduces to normal form, function application does indeed proceed from left to right, but we have to take into account the declared precedence of particular functions / operators.</div><div><br></div><div>Is my thinking correct here? Are there any particular holes in this logic? I still don't think I'd be able to figure out "where the parenthesis go" if I was given a new expression with functions / operators with 3 or 4 different declared precedences. For a beginner, is that a huge problem, or is knowledge of the concept enough?</div></div>