[Haskell-cafe] Haskell wiki: most popular pages

Tim Walkenhorst tim.walkenhorst at gmx.de
Fri Aug 18 08:26:46 EDT 2006


> [...] it's just a pleasure to see all those one-line definitions
> and feel how power the language should be to allow such cool things.
>   

It is indeed. I find these explicit definitions often much more 
instructive than purely implicit definitions. But, call me a nitpicker, 
some of the definitions are still a bit longish for my taste.

For example:

break :: (a -> Bool) -> [a] -> ([a],[a])
break p xs

  = span <http://undergraduate.csse.uwa.edu.au/units/230.301/lectureNotes/tourofprelude.html#span> p' xs
    where
    p' x = not <http://undergraduate.csse.uwa.edu.au/units/230.301/lectureNotes/tourofprelude.html#not> (p x)


could be written as:

break p = span (not . p)

or:

and xs = foldr <http://undergraduate.csse.uwa.edu.au/units/230.301/lectureNotes/tourofprelude.html#foldr> (&&) True xs

as:

and = foldr <http://undergraduate.csse.uwa.edu.au/units/230.301/lectureNotes/tourofprelude.html#foldr> (&&) True


While the second case is pure nitpicking, I find that the point-free 
definition is much easier to read in the first case. Any reason to use 
the point-wise notation there? Is it considered to be easier to read or 
understand?


More information about the Haskell-Cafe mailing list