[Haskell-cafe] Re: Very crazy

Derek Elkins derek.a.elkins at gmail.com
Tue Sep 25 22:22:02 EDT 2007


On Tue, 2007-09-25 at 12:24 +0100, Andrew Coppin wrote:
> Chaddaï Fouché wrote:
> > 2007/9/25, Andrew Coppin <andrewcoppin at btinternet.com>:
> >   
> >> This is why I found it so surprising - and annoying - that you can't use
> >> a 2-argument function in a point-free expression.
> >>
> >> For example, "zipWith (*)" expects two arguments, and yet
> >>
> >>   sum . zipWith (*)
> >>
> >> fails to type-check. You just instead write
> >>
> >>   \xs ys -> sum $ zipWith(*) xs ys
> >>
> >>     
> >
> > (sum . zipWith (*)) xs ys
> > == (sum (zipWith (*) xs)) ys
> >
> > so you try to apply sum :: [a] -> Int to a function (zipWith (*) xs)
> > :: [a] -> [b], it can't work !
> >
> > (sum.) . zipWith (*)
> > works, but isn't the most pretty expression I have seen.
> >   
> 
> I'm still puzzled as to why this breaks with my example, but works 
> perfectly with other people's examples...
> 
> So you're saying that
> 
>   (f3 . f2 . f1) x y z ==> f3 (f2 (f1 x) y) z
> 
> ? In that case, that would mean that
> 
>   (map . map) f xss ==> map (map f) xss
> 
> which *just happens* to be what we want. But in the general case where 
> you want

>   f3 (f2 (f1 x y z))
> 
> there's nothing you can do except leave point-free.

As people have pointed out, you can do this, and in fact, can -always-
do this, i.e. always write things "point-free."  lambdabot's @pl
command, as mentioned elsewhere, is a constructive proof of this.
However, I'm composing this email to point out a historical fact:
Essentially, "writing everything point-free" was Haskell Curry's
research programme.  See the field of combinatory logic of which he is
one of the fathers.



More information about the Haskell-Cafe mailing list