[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Original-Via: uk.ac.york.minster; Mon, 22 Oct 90 11:46:41 BST
Date:       22 Oct 1990 11:04:47 GMT
From: colin@minster.york.ac.uk
To: haskell@cs.glasgow.ac.uk
Sender: haskell-request@cs.glasgow.ac.uk

re: sections

I too would like to raise the question of sections (cf Evan Ireland's
mail of 9 Oct).  I have recently translated into Haskell the solutions
to various introductory programming exercises, previously expressed in
a language with sections, and I wished that this notation was available
in Haskell.  In the language as it stands, there are two alternative
notations for the partial application of an operator to a single
argument (either a left argument L or a right argument R):

A. a lambda abstraction: "\x -> x op R" or "\x -> L op x"

B. a function application: "(op) L" or "C (op) R"
   (where "C" is the usual combinator: C f x y = f y x.)

Both forms are very likely to require surrounding brackets, and the
abstraction style A. is particularly verbose compared with the sectional
alternatives "(op R)" and "(L op)".

The application style B. has a particularly nasty characteristic:
a partial application to a left argument **looks** more like a partial
application to a right argument. This makes the notation very error
prone for non-commuting operators.  It is difficult NOT to read

  filter ((<) x) ys

as "the items in ys less than x", for example.
In partial applications to right arguments, the need for the
combinator is mildly irritating - it is more of a coding trick
than a natural form of expression.

Since my notational preferences in programming are usually "minimalist"
I am slightly surprised to find myself advocating a notational extension
in an already rich language.  But sections exhibit so well those
twin pillars of minimalist civilisation - brevity and clarity - that
I am reluctant to do without them.

-----------------------------------------------------------------------
Dr Colin Runciman		Telephone +44 904 432740
Department of Computer Science	
University of York		JANET:	colin@uk.ac.york.minster
YORK Y01 5DD
United Kingdom			UUNET:	uucp!ukc!minster!colin
-----------------------------------------------------------------------