[Haskell-cafe] Re: what are the points in pointsfree?

ajb at spamcop.net ajb at spamcop.net
Fri Dec 15 00:09:13 EST 2006

G'day all.

Quoting Steve Downey <sdowney at gmail.com>:

> from what you just told me, it's not an artifact of the pf style, but
> that maximally reusable functions will be expressible in a pointsfree
> style.

Not necessarily.  (There's a fairly obvious reductio ad absurdum argument
as to why: at least the primitives like "map" and "foldr" need to be
expressed in a pointed way!)

Pointsfree functions are not necessarily maximally reusable, but they're
usually maximally refactorable.

As an example, the associative law for monads looks like this in
pointed style:

    (m >>= k1) >>= k2  =  m >>= (\x -> k1 x >>= k2)

Applying this law from left to right requires introducing a fresh
variable, which involves checking for name clashes, even if only
briefly, and introduces a new name that doesn't necessarily have a
good "meaning".

Applying the law from right to left might require a lot of fiddling
with k1 to get it in the right form, and checking that the variable,
x, is not free in m or k2.

In point-free style, the associative law for monads looks like this:

    join . join  =  join . fmap join

In either direction, this is almost trivial.

Andrew Bromage

More information about the Haskell-Cafe mailing list