In Haskell (and many other functional languages) it's quite common for the implementation of a function to reference one less argument than the type signature declares:

g :: foo -> bar
g = length . reverse

Known as point-free style by proponents (and pointless style by opponents), the function definition is a list of other functions which are composed together to produce a composite requiring a single argument: the missing one.

Sometimes I come across the opposite: a function with a type signature and a definition beginning in a way similar to this

f :: foo -> bar
f a b = …

That is, the type signature declares that the function accepts a single argument of type foo, but the definition is in terms of two arguments. Huh?

What's going on is that bar is really a type synonym for another function. In other words

type bar = baz -> qux

So we can consider f to actually be

f :: foo -> baz -> qux

With this definition of bar, in the definition of f above, the second parameter b maps to the type baz.

When I've encountered this, I strongly suspect what has happened is the function was originally written with the longer type signature, and later on the type synonym was declared and function signatures updated to use it. I'm not aware of anyone advocating for this style.


Comments

comment 1
Should we call that weird case "point-five style" (i.e. 0.5 style), since it's halfway like point-free?
Comment by Phil,