From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA19304 for caml-redistribution; Mon, 21 Sep 1998 19:49:40 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA16297 for ; Mon, 21 Sep 1998 18:31:14 +0200 (MET DST) Received: from Cs.Nott.AC.UK (pat.cs.nott.ac.uk [128.243.21.19]) by nez-perce.inria.fr (8.8.7/8.8.7) with SMTP id SAA19287 for ; Mon, 21 Sep 1998 18:31:12 +0200 (MET DST) Received: from marian.cs.nott.ac.uk by pat.Cs.Nott.AC.UK id aa11354; 21 Sep 98 17:30 BST Received: from localhost by marian.Cs.Nott.AC.UK id aa27223; 21 Sep 98 17:30 BST Sender: weis Message-ID: <36067F2A.22FE@cs.nott.ac.uk> Date: Mon, 21 Sep 1998 17:30:34 +0100 From: Peter J Thiemann Organization: Computer Science, University of Nottingham X-Mailer: Mozilla 3.01 (X11; I; SunOS 5.6 sun4m) MIME-Version: 1.0 To: caml-list@inria.fr CC: pjt@cs.nott.ac.uk Subject: polymorphic recursion Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit In some languages (most notably Haskell and Miranda) it is possible to define a function that enjoys polymorphic recursion, i.e., the types of its recursive calls may be instances of the type scheme at which the function is defined. For example: let rec f x = let q = f true in let r = f 0 in x;; is rejected by OCaml, but it is accepted by Haskell by saying f :: a -> a f x = let q = f True in let r = f 0 in x Question: Can you do the same in OCaml? I am aware of the tricks mentioned in the FAQ, but I would like to know if there is a cleaner way to do it, for example by providing a type signature. -Peter