From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA16291; Mon, 2 Dec 2002 00:42:00 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA16272 for ; Mon, 2 Dec 2002 00:41:59 +0100 (MET) Received: from nexus.stwing.upenn.edu (NEXUS.STWING.UPENN.EDU [165.123.132.61]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gB1NfwX03939 for ; Mon, 2 Dec 2002 00:41:58 +0100 (MET) Received: from force.stwing.upenn.edu (daemon@force.stwing.upenn.edu [165.123.132.65]) by nexus.stwing.upenn.edu (8.11.6/8.11.6) with ESMTP id gB1NftI06893 (using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified NO) for ; Sun, 1 Dec 2002 18:41:56 -0500 (EST) Received: (from wlovas@localhost) by force.stwing.upenn.edu (8.11.6/8.11.6) id gB1NftE05230 for caml-list@inria.fr; Sun, 1 Dec 2002 18:41:55 -0500 (EST) Date: Sun, 1 Dec 2002 18:41:55 -0500 From: William Lovas To: caml-list@inria.fr Subject: Re: [Caml-list] Understanding why Ocaml doesn't support operator overloading. Message-ID: <20021201234154.GA4301@force.stwing.upenn.edu> Mail-Followup-To: caml-list@inria.fr References: <20021130214138.GA19662@force.stwing.upenn.edu> <200212011730.SAA10480@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200212011730.SAA10480@pauillac.inria.fr> User-Agent: Mutt/1.4i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, Dec 01, 2002 at 06:30:55PM +0100, Pierre Weis wrote: > > As an exercise, try to write a useful function that operates > > on just 'a's -- you'll find it a challenge :) (in fact, i think there's a > > theorem in one of Philip Wadler's papers that says the *only* function of > > type 'a -> 'a in a purely functional language is the identity function). > > This is a theorem that was stated about $\lambda$-calculus long time > ago, way before Phil Wadler's papers, back to Reynolds as I remember. That's probably true -- i just happened to remember it from a Wadler paper. > The challenge you proposed is not so difficult in Caml. You can easily > define functions that operates on justs'a's, or even just return plain > 'a's! > > Objective Caml version 3.06+18 (2002-11-07) > > # raise;; > - : exn -> 'a = > # ignore;; > - : 'a -> unit = Mmm, this certainly is a useful use of polymorphism without parametrized, types, but the challenge i was trying to propose was more to the spirit of the original 'a -> 'a theorem: by "useful function that operates on just 'a's", what i meant was essentially "a non-trivial function of type 'a -> 'a", which is (i hope) a significantly more difficult challenge :) Polymorphism as used in `raise' and `ignore' strikes me as more language magic than anything else -- although useful in practice, i have a strong intuition that from a certain theoretical perspective, namely that of purely functional languages, they're not so interesting. So, to clarify, while they are practical uses of polymorphism, they're not what i had in mind when i wrote the above paragraph. Thanks for the corrections and pointers! cheers, William ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners