Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] really HO Functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-09-29 (19:23)
From: Jacques Carette <carette@m...>
Subject: RE: [Caml-list] really HO Functions
The best answer is from Chris Okasaki in
Even Higher-Order Functions for Parsing or Why Would Anyone Ever Want To Use
a Sixth-Order Function? by Chris Okasaki. Journal of Functional Programming,
8(2):195-199, March 1998.

Abstract: We illustrate the use of third-, fourth-, fifth-, and even
sixth-order functions with examples taken from a combinator parsing library.

Available at


-----Original Message-----
[] On Behalf Of Radu Grigore
Sent: September 29, 2004 2:48 PM
To: caml-list
Subject: [Caml-list] really HO Functions

For this message I'll classify functions on "levels" based on how many
nested parenthesis are needed to represent their type.

Functions of level 0 (e.g. int -> int, char -> int -> int, ...) are the most
used in programming. In widespread languages like C#, Java and C++ they are
almost the only kind of functions used.

Functions of level 1 (e.g. ('a -> 'b) -> ('b -> 'c) -> ('a -> 'c)) are used
a lot when programming in a functional language. They are also the ones that
appear in examples and tutorials written for imperative programmers. This
category includes fold, iter, map, composition.

However a language like OCaml allows N to go up as much as you want. My
question is: are there functions of level >= 2 used in practice (e.g. (('a
-> 'b -> 'a) -> 'a -> 'b list -> 'a) -> 'c)? If so, are there any typical
ones that appear in many applications (maybe not as widespread like map &
company but at least of comparable usefulness)? One example of a level 2
function (stolen from a recent post by Jon
Harrop) is this:
  let sum fold = fold (+);;


To unsubscribe, mail Archives: Bug reports: FAQ: Beginner's list:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: