From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 6951C7EE1A for ; Fri, 30 Nov 2012 17:49:00 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of daniel.buenzli@erratique.ch) identity=pra; client-ip=74.55.86.74; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="daniel.buenzli@erratique.ch"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of daniel.buenzli@erratique.ch) identity=mailfrom; client-ip=74.55.86.74; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="daniel.buenzli@erratique.ch"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.webfaction.com) identity=helo; client-ip=74.55.86.74; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="postmaster@smtp.webfaction.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkoBABTjuFBKN1ZKm2dsb2JhbABEg2SCSLl3DgEBAQEBCAkUFCeCHgEBBAEjBE0FBQsLGgImAgJHEAYbiAIGBAOtBpJ8gSKLHhuDEzJhA5cchDwTg1+BbYgAgWs X-IronPort-AV: E=Sophos;i="4.84,192,1355094000"; d="scan'208";a="184024720" Received: from mail6.webfaction.com (HELO smtp.webfaction.com) ([74.55.86.74]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 Nov 2012 17:48:28 +0100 Received: from [172.20.10.4] (15-233.197-178.cust.bluewin.ch [178.197.233.15]) by smtp.webfaction.com (Postfix) with ESMTP id DE9CE207D4A9; Fri, 30 Nov 2012 10:48:25 -0600 (CST) Date: Fri, 30 Nov 2012 17:48:21 +0100 From: =?utf-8?Q?Daniel_B=C3=BCnzli?= To: Gabriel Scherer Cc: caml-list@inria.fr Message-ID: In-Reply-To: References: <50B822A6.7000504@emu-bark.com> <20121130100601.GA27413@upsilon.cc> X-Mailer: sparrow 1.6.4 (build 1178) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Caml-list] List.fold_left vs. Hashtbl.fold Le vendredi, 30 novembre 2012 =C3=A0 17:00, Gabriel Scherer a =C3=A9crit : > I don't know. "function application is just space" is indeed a > convenient syntax to emulate other syntaxes (for example embed a > concatenative language through cunning continuation-passing-style), My concern is not really about the syntax. > but that doesn't need to go away with non-currified functions, which > is about applying all arguments, not necessarily forcing a tupled > syntax. That's the point, currying allows you to build a function incrementally wit= h things happening between each applied argument.=20=20 This is for example very useful to meta-program other languages from OCaml = (using the abstraction mechanisms and variable binders of OCaml itself). It= may not be very clear (the whole program is not here, if you are intereste= d I can mail you the whole example), but with the combinators given at the = end of this message, I'm able to gradually construct a program representing= a function in another language, with an arbitrary number of arguments, com= pile it, and then get it as regular OCaml function (Program.as_fun) that us= es OCaml gound types and that can be passed around completely hiding that t= he function may actually not be executed by OCaml at all. Currying gives you glue, I'm not sure you could do these kind of things wit= hout it. If you can't then currying is not overrated to me. See also http:/= /mlton.org/Fold Best, Daniel type 'a exp (* expressions constructed with combinators *) module Program : sig type 'a t=20=20 type ('a, 'b, 'c) stage (* b is the type of the constructed function *) (* Note. The types enforces that only caml functions from 'a exp(s) to 'a exp will be accepted for compilation into a program. *) val retb : ('a exp -> 'b) -> ('a exp -> 'b, bool , [`Bool ]) stage val reti : ('a exp -> 'b) -> ('a exp -> 'b, int , [`Int ]) stage val retf : ('a exp -> 'b) -> ('a exp -> 'b, float, [`Float]) stage val argb : (bool_e -> 'a, 'b, 'c) stage -> ('a, bool -> 'b, 'c) stage=20= =20 val argi : (int_e -> 'a, 'b, 'c) stage -> ('a, int -> 'b, 'c) stage val argf : (float_e -> 'a, 'b, 'c) stage -> ('a, float -> 'b, 'c) stage val compile : ('a exp, 'b, 'a) stage -> 'b t val as_fun : 'a t -> 'a val source : 'a t -> string end