Contents

It is very common for functional programmers to write functions as a
composition of other functions, never mentioning the actual arguments
they will be applied to. For example, compare:

sum=foldr(+)0

with:

sum' xs = foldr (+) 0 xs

These functions perform the same operation, however, the former is more
compact, and is considered cleaner. This is closely related to function
pipelines (and to unix shell scripting

): it is clearer to write

let fn = f . g . h

than to
write

let fn x = f (g (h x))

.

This style is particularly useful when deriving efficient programs by
calculation, but it is good discipline in general. It helps the writer
(and reader) think about composing functions (high level), rather than
shuffling data (low level).

It is a common experience when rewriting expressions in pointfree style
to derive more compact, clearer versions of the code -- explicit points
often obscure the underlying algorithm.

1 But pointfree has more points!

A common misconception is that the 'points' of pointfree style are the

(.)

operator (function composition, as an ASCII symbol),

which uses the same identifier as the decimal point. This is wrong. The
term originated in topology, a branch of mathematics which works with
spaces composed of points, and functions between those spaces. So a
'points-free' definition of a function is one which does not explicitly
mention the points (values) of the space on which the function acts. In
Haskell, our 'space' is some type, and 'points' are values. In the
declaration:

f x = x +1

we define the function

f

in terms of its action on an
arbitrary point

x

. Contrast this with the points-free

version:

f =(+1)

where there is no mention of the value on which the function is acting.

2 Background

To find out more about this style, search for Squiggol and the
Bird-Meertens Formalism, a style of functional programming by
calculation that was developed by Richard Bird, Lambert Meertens, and
others at Oxford University. Jeremy Gibbons has also written a number of
papers about the topic, which are cited below.

3 Tool Support

Thomas Yaeger has
written a
Lambdabot
plugin to automatically convert a large subset of Haskell expressions to
pointfree form. This tool has made it easier to use the more abstract
pointfree encodings (as it saves some mental gymnastics on the part of
the programmer). You can experiment with this in the Haskell IRC channel.

The @pl (point-less) plugin is rather infamous for using the

(-> a)

monad to obtain concise code. It also makes use of Arrows.
It also sometimes produces (amusing) code blow ups with the

4.2 Swing

4.3 Squish

f >>= a . b . c =<< g

Example:

(readFile y >>=).((a . b).). c =<<readFile x

5 Obfuscation

Point-free style can (clearly) lead to Obfuscation when used unwisely.
As higher-order functions are chained together, it can become harder to
mentally infer the types of expressions. The mental cues to an
expression's type (explicit function arguments, and the number of
arguments) go missing.

Perhaps this is why pointfree style is sometimes (often?) referred to as
pointless style.

6 References

One early reference is

Backus, J. 1978. "Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs," Communications of the Association for Computing Machinery 21:613-641.

A Calculus of Functions for Program Derivation, R.S. Bird, in Res Topics in Fnl Prog, D. Turner ed, A-W 1990.

The Squiggolist, ed Johan Jeuring, published irregularly by CWI Amsterdam.

Pointless Haskell is a library for point-free programming with recursion patterns defined as hylomorphisms. It also allows the visualization of the intermediate data structure of the hylomorphisms with GHood. This feature together with the DrHylo tool allows us to easily visualize recursion trees of Haskell functions. Haskell Manipulation by Jose Miguel Paiva Proenca discusses this tool based approach to re-factoring.

This project is written by Manuel Alcino Cunha, see his homepage for more related materials on the topic.
An extended verson of his paper Point-free Programming with Hylomorphisms can be found here.