-->

Where does the name “section” come from for a part

2020-08-11 05:22发布

问题:

In Haskell, we use the term "section" to indicate a partially applied function used in infix position. For instance, for a function foo :: a -> b -> c and values x :: a and y :: b, we have the two sections

s1 = (x `foo`) :: b -> c == \b -> foo x b

and

s2 = (`foo` y) :: a -> c == \a -> foo a y

In category theory, however, a section g of f is defined as a right inverse of f (so that f . g == id).

I don't see an obvious connection between the two definitions. For instance, s1 is clearly not an inverse of foo, at least not in Hask. I suppose s1 doesn't even have to have an inverse in Hask.

Is the category-theoretical definition the source of the Haskell definition, and if so, how?

回答1:

As has been pointed out in the comments, Haskell got the sections from Miranda (and Orwell). David Turner says he got the idea from Richard Bird and David Wile.

I have just chatted with Richard Bird. He says he doesn't remember where the name came from, but he thinks it was David Wile who coined it. Unfortunately, David Wile died last year, so we will probably never know. But, Richard did admit that he was the one who convinced David Turner and Phil Wadler to add sections in their languages.

Here's the page from Wile's thesis that is the first know mention of "section". http://imgur.com/a/cQDlu



回答2:

Possibly, it comes from "array section" operation, used primarily in Fortran, particularly for column or row extraction. That makes sense, if you consider making lookup table from two-argument function. https://www.phy.ornl.gov/csep/pl/node16.html