<div dir="ltr"><div>If I understand correctly, you're asking why function application is left-associative rather than right-associative. With currying and first-class functions, right-association doesn't really work well. It's not obvious with a highly-constrained function like "max", but in practice most Haskell functions get composed and applied with other functions; real data only matters at the endpoints. For a reasonably simple example, consider the interaction between a couple of other Prelude functions:</div><div><br></div><div>map :: (a -> b) -> [a] -> [b]</div><div>const :: a -> b -> a</div><div><br></div><div>Since (b -> a) is a type all by itself, it fits into a type variable for other functions; that is, "const" is an (a -> b) for the purposes of filling the first argument of "map". Applying this gets:<br></div><div><br></div><div>map const :: [a] -> [b -> a]</div><div><br></div><div>This takes a list of values, and returns a list of functions. So considering the type of "map const", which of the following behaviors seems more appropriate:</div><div><br></div><div>> :t (map const) [1,2,3]<br></div><div>map const [1,2,3] :: Num a => [b -> a]<br></div><div><br></div><div>> :t map (const [1,2,3])</div><div>map (const [1,2,3]) :: Num a => [b] -> [[a]]<br></div><div><br></div><div>Haskell chooses the first option, because giving an argument [a] to an expression whose type is currently [a] -> [b -> a] should probably return [b -> a].</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 4, 2016 at 12:43 AM, OxFord <span dir="ltr"><<a href="mailto:fordforox@gmail.com" target="_blank">fordforox@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>Hello,<br><br></div>why Haskell doesn't apply functions in preorder? <br></div>e.g.<br><br></div>f x = x<br><br></div>max 1 f 2<br>> 2<br></div>max f 1 f 2<br>> 2<br></div>max max f 1 f 2 f 3<br>> 3<br></div>f f f f f f f f f f f 1<br>> 1<br><br><br></div>Thus you would need to put the arguments into brackets only when you want to partially apply that function.<br><br><br></div>Is the current method more readable or error prone?<br><br></div>King regards,<br><br></div>Ford<br></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>