<html>
<body>
Hi,<br><br>
At 01:56 12-10-2005, lethevert wrote:<br>
<blockquote type=cite class=cite cite="">In StdEnv Library, these
functions are defined.<br><br>
fwritec<x-tab>&nbsp;</x-tab><x-tab>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>:: !Char !*File
-&gt; *File<br>
fwritei<x-tab>&nbsp;</x-tab><x-tab>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>:: !Int !*File
-&gt; *File<br>
fwriter<x-tab>&nbsp;</x-tab><x-tab>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>:: !Real !*File
-&gt; *File<br>
fwrites<x-tab>&nbsp;</x-tab><x-tab>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>:: !{#Char}
!*File -&gt; *File<br><br>
But why parameters are in this order?</blockquote><br>
It is (next to) impossible to determine an optimal order of arguments for
functions. The chosen order is convenient to write definitions
like:<br><br>
<tt>endl :: (*File -&gt; *File)<br>
endl = fwrites &quot;\n&quot;<br><br>
helloWorld :: (*File -&gt; *File)<br>
helloWorld = fwrites &quot;\n&quot; o fwrites &quot;World!&quot; o
fwrites &quot; &quot; o fwrites &quot;Hello&quot; <br><br>
</tt><blockquote type=cite class=cite cite="">Recently I found it's
useful to write like below;<br><br>
printSomeStringList :: *File [String] -&gt; *File<br>
printSomeStringList f lst<br>
&nbsp;&nbsp;&nbsp; = foldl (\f s = fwrites s f) f lst</blockquote><br>
Since arguments are often in the other order as needed in the current
application, <tt>StdEnv </tt>provides <tt>flip </tt>to reverse arguments.
It is defined as<br><br>
<tt>flip f a b :== f b a<br><br>
</tt>using this your <tt>printSomeStringList</tt> can be defined
as<br><br>
<tt>printSomeStringList :: (*File -&gt; *([String] -&gt; *File))<br>
printSomeStringList = foldl (flip fwrites)<br><br>
</tt>A similar problem exists with the priority of infix operators: it is
(next to) impossible to determine priorities such that you never have to
write parenthesis.<br><br>
I don't want to claim that the order of arguments of <tt>fwrites</tt> or
the priority of <tt>&lt;&lt;&lt;</tt> is optimal, for any choice there
will be examples where it works fine and examples where it is
inconvenient.<br>
In general there must be very strong arguments to change such things in
the library since it can stop existing programs to work
correctly.<br><br>
Have fun,<br><br>
Pieter Koopman <br>
</body>
</html>