[clean-list] order of parameters of "fwrites"
Marco Kesseler
m.kesseler at xs4all.nl
Wed Oct 12 20:41:22 MEST 2005
erik.zuurbier at tiscali.nl wrote:
>One reason is the possibility to chain various write-functions with <<<
>as follows:
>where file1 = file <<< fwritec 'A' <<< fwritei 12 <<<
>fwrites "abc"
>
>
>
Funny that you mention this, because the type of (<<<) actually is:
class (<<<) infixl a :: !*File !a -> *File
which is exactly the kind of argument reversal that the original poster
suggested. The compiler won't accept the code above. The expression
goes like: file <<< 'A' <<< 12 <<< "abc". The instance definitions for
<<< actually reverse the arguments before mapping onto fwrites, fwritei,
etc.
Now as to the original fold problem: you can also solve this by defining
a fold that applies the arguments in the reverse order to the operation.
rfoldl op r l :== foldl r l
where
foldl r [] = r
foldl r [a:x] = foldl (op a r) x
regards
Marco
More information about the clean-list
mailing list