From: Pierre Weis <Pierre.Weis@inria.fr>
To: whitley@cse.buffalo.edu (John Whitley)
Cc: caml-list@inria.fr
Subject: Re: Functional composition operator?
Date: Tue, 8 Dec 1998 18:02:21 +0100 (MET) [thread overview]
Message-ID: <199812081702.SAA29130@pauillac.inria.fr> (raw)
In-Reply-To: <13932.45585.522844.651609@hadar.cs.Buffalo.EDU> from "John Whitley" at Dec 8, 98 00:23:59 am
> Andrew Kay <akay@sharp.co.uk> wrote, in the caml-list archives:
> > We are in the process of converting our Caml code into OCaml, and
> > have a problem choosing an infix syntax for function composition
> > [...] What do other OCaml people use for function composition? Is
> > there standard emerging?
>
> I found no answer in the archives, so I'd like to raise the same
> question again: is there a consensus for choice of infix composition
> operator? Failing that, is there some design principle that warranted
> its omission?
>
> Thanks,
> John Whitley
The normal infix operator should be a o, or more precisely a $\circ$
symbol. Unfortunately if we add o in the syntax of Caml, this will be
a bit strange to have this identifier as an infix operation (moreover
this implies difficult to explain syntax errors in programs).
In fact we discourage the usage of functional composition as a general
programming tool, since:
-- it only save a few characters in programs
(Compare
let h = f o g
with
let h x = f (g x);;)
-- it breaks the polymorphism
(if defined as
let h = f o g
h is not generalized, since its definition is a function
application, whereas inline expansion of functional composition
let h x = f (g x)
being the definition of a function is properly generalized.)
-- it is not so clear, especially in case of composition of curried
functions
(Consider
let f x y z = x + y + z
then the compositions
f o (f 2 3)
or (f 1) o (f 2 3))
It is still possible to define a composition operator to use in
trivial cases. So you may choose any multi-character infix operator
such as ++, if you really need functional composition.
Best regards,
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/
next prev parent reply other threads:[~1998-12-08 18:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-08 5:23 John Whitley
1998-12-08 17:02 ` Pierre Weis [this message]
1998-12-08 21:52 ` John Harrison
1998-12-09 10:58 ` Pierre Weis
1998-12-09 17:17 ` John Harrison
1998-12-11 13:57 ` Pierre Weis
1998-12-08 18:08 Andrew Kay
1998-12-08 20:32 ` John Prevost
1998-12-09 16:17 ` Anton Moscal
1998-12-08 19:51 Don Syme
1998-12-08 20:09 Don Syme
1998-12-09 12:00 Don Syme
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199812081702.SAA29130@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=caml-list@inria.fr \
--cc=whitley@cse.buffalo.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox