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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9BE397F20B for ; Thu, 7 Feb 2013 21:04:40 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.187; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.187; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.126.187 as permitted sender) identity=helo; client-ip=212.227.126.187; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqoAAGcIFFHU4367k2dsb2JhbAA8Ca1uknwWDgEBAQEJCQsJFAMkgiABBScTNAsQGRchIRsJEgYTCQmHbQMTCLYXAwqJVhWIXoMjgQWEQQONcIZZgnWKIogU X-IPAS-Result: AqoAAGcIFFHU4367k2dsb2JhbAA8Ca1uknwWDgEBAQEJCQsJFAMkgiABBScTNAsQGRchIRsJEgYTCQmHbQMTCLYXAwqJVhWIXoMjgQWEQQONcIZZgnWKIogU X-IronPort-AV: E=Sophos;i="4.84,623,1355094000"; d="scan'208";a="1459449" Received: from moutng.kundenserver.de ([212.227.126.187]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Feb 2013 20:57:33 +0100 Received: from office1.lan.sumadev.de (dslb-084-059-074-050.pools.arcor-ip.net [84.59.74.50]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0MaQ2u-1UNOwg3VKC-00JnlV; Thu, 07 Feb 2013 21:04:39 +0100 Received: from samsung (546BF816.cm-12-4d.dynamic.ziggo.nl [84.107.248.22]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 5DF3CC00CF; Thu, 7 Feb 2013 21:04:38 +0100 (CET) Date: Thu, 07 Feb 2013 21:04:37 +0100 From: Gerd Stolpmann To: Jeff Meister Cc: Ashish Agarwal , Caml List References: In-Reply-To: (from nanaki@gmail.com on Thu Feb 7 20:53:25 2013) X-Mailer: Balsa 2.4.11 Message-Id: <1360267477.18230.9@samsung> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; DelSp=Yes; Format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Provags-ID: V02:K0:H0GPluq7PU67UE1+ldRqxp9rOBhflKv8fMd9TZnnXTG vvq/iND73NpAKa2L3V1tz4G1IQGIJ4gUsF2uMTAoSMkKDzSh4P 8jvy0JtpbxJWTSNBGrZgLcfW0QioBtRwYan9+HZPtIc+LIcOI6 SCdWDCN2DtYpX48bSIvTlrrZr9Me0aFrdb7jKPFo23z+1kPMzw GOYigUt3in3XrQSmuLT6SB7slliv1tzINQGzCpKhtwHKapnLac IFMyFpaA9rsxsAXVw5plFoSZ+23ef+t5LfYAMcb/MVcKb0A6Q6 VmVr76peWbrciNl4cLx/wNGoMngsRkO+mmzlH6Lue7ooxk/Qlt sbuTh8UlqPV9japB+w78= Subject: AW: [Caml-list] use identity for default function Nope: # external id : 'a -> 'b =3D "%identity";; external id : 'a -> 'b =3D "%identity" # (id 5);; - : 'a =3D # ((id 5) : string);; Signal -10 # external id : 'a -> 'b =3D "%identity";; external id : 'a -> 'b =3D "%identity" # let foo ?(f =3D id) x =3D f x;; val foo : ?f:('a -> 'b) -> 'a -> 'b =3D # foo 5;; - : 'a =3D # ((foo 5):string);; Signal -10 I think it is not sound what Ashish wants: If f is not passed, the type=20= =20 checker needs to add a constraint about the return value. This looks=20=20 like a dependent type. Gerd Am 07.02.2013 20:53:25 schrieb(en) Jeff Meister: > Can't you simply define it this way? (I don't think I'm using any new > features, so maybe I misunderstood your question.) >=20 > OCaml version 4.00.1 >=20 > # external id : 'a -> 'b =3D "%identity";; > external id : 'a -> 'b =3D "%identity" > # let foo ?(f =3D id) x =3D f x;; > val foo : ?f:('a -> 'b) -> 'a -> 'b =3D >=20 >=20 > On Thu, Feb 7, 2013 at 11:22 AM, Ashish Agarwal=20=20 > wrote: >=20 > > I'd like to implement > > > > val foo : ?f:('a -> 'b) -> 'a -> 'b > > > > where the default for f is identity. Is there now a way to do this=20= =20 > with > > all the new features of OCaml? > > > > >=20 > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------=