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 LAA32591; Thu, 20 Nov 2003 11:45:53 +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 LAA32554 for ; Thu, 20 Nov 2003 11:45:52 +0100 (MET) Received: from oxy.exomi.com (fa-3-0-0.fw.exomi.com [217.169.64.99]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAKAjp121825 for ; Thu, 20 Nov 2003 11:45:51 +0100 (MET) Received: by oxy.exomi.com (Postfix, from userid 501) id 030D9B55A2; Thu, 20 Nov 2003 12:45:54 +0200 (EET) Date: Thu, 20 Nov 2003 12:45:54 +0200 From: Ville-Pertti Keinonen To: Peter Scott Cc: caml-list@inria.fr Subject: Re: [Caml-list] Recursive apply function Message-ID: <20031120104554.GA1387@exomi.com> Mail-Followup-To: Peter Scott , caml-list@inria.fr References: <5.2.0.9.0.20031119204912.00a9fb28@127.0.0.1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5.2.0.9.0.20031119204912.00a9fb28@127.0.0.1> User-Agent: Mutt/1.4.1i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 typecheck:01 -rectypes:01 implemented:01 recursively:01 -rectypes:01 resorting:01 0700,:01 lisp:01 nov:01 side-effects:02 partially:02 identical:03 typing:03 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Nov 19, 2003 at 08:54:08PM -0700, Peter Scott wrote: > first element of the list. Unfortunately, I get this message when run: > "This expression has type 'a but is here used with type 'b -> 'a", > referring to the "(f arg)" part. You can get your "apply" function to typecheck using the -rectypes option, but it still doesn't do what you want; it only accepts functions that return functions of the same (recursive) type. Static typing prevents things like Lisp apply from being implemented even for the limited case where arguments have the same type. The type of a partially applied function is almost never identical to the fully applied function (except for the case of recursively typed functions that return functions, such as your "apply"). Note that the -rectypes option is probably not something you want to use unless you know that you need it. An example is if you want to have a state machine with functions representing states without resorting to side-effects (f : event -> action * 'a as 'a). ------------------- 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