Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the point-free style called point free in Haskell when it is full with points? Where does the term "point-free" originates from?

I am currently reading Learn You a Haskell for Great Good and I came across the notion "point-free style" on page 85 as shown below. However, the fn function is full with points! This confuses me.

  • Why is this style of writing functions called "point-free" when it is full with points ?

  • How should I understand this notion ? "Point-free" in what sense ?

  • Where is the term "point-free style" originates from ? Perhaps from a language where function composition was denoted by space ?

PS: So far this is the only confusing part in this excellent book (i.e. in the first 85 pages I have read so far).

enter image description here

like image 535
jhegedus Avatar asked Feb 25 '14 08:02

jhegedus


People also ask

What is point free style Haskell?

Point free style means that the code doesn't explicitly mention it's arguments, even though they exist and are being used. This works in Haskell because of the way functions work. For instance: myTake = take.

What is the point of point free code?

Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments (or "points") on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments.


2 Answers

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.

from haskellwiki

like image 184
cnd Avatar answered Feb 07 '23 03:02

cnd


Basically, each local variable is a "point". A function with no local variables is therefore "point-free".

like image 32
MathematicalOrchid Avatar answered Feb 07 '23 01:02

MathematicalOrchid