[Haskell-cafe] Re: Point-free style
Daniel Fischer
daniel.is.fischer at web.de
Thu Feb 10 14:47:56 EST 2005
Am Donnerstag, 10. Februar 2005 16:53 schrieb Peter Simons:
> Jan-Willem Maessen writes:
> > Is it really clear or obvious what
> >
> > map . (+)
> >
> > means?
>
> Yes, it is perfectly obvious once you write it like this:
>
> incrEach :: Integer -> [Integer] -> [Integer]
> incrEach = map . (+)
Yes, but without the type signature it isn't really (to a beginner, at least).
>
> Now compare that to the following function, which does the
> some thing but without point-free notation:
>
> incrEach' :: Integer -> [Integer] -> [Integer]
> incrEach' i is = is >>= \i' -> return (i'+i)
Ugh, but I think the natural way to write it looks more like
incrAll :: Integer -> [Integer] -> [Integer]
incrAll n ks = map (+n) ks
which is no less readable than map . (+).
>
> Which one is harder to read? ;-)
>
> Peter
>
Daniel
More information about the Haskell-Cafe
mailing list