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 0E0F87F20B for ; Thu, 7 Feb 2013 20:53:27 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nanaki@gmail.com) identity=pra; client-ip=209.85.128.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nanaki@gmail.com"; x-sender="nanaki@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of nanaki@gmail.com designates 209.85.128.173 as permitted sender) identity=mailfrom; client-ip=209.85.128.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nanaki@gmail.com"; x-sender="nanaki@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ve0-f173.google.com) identity=helo; client-ip=209.85.128.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nanaki@gmail.com"; x-sender="postmaster@mail-ve0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlQBALwFFFHRVYCtkWdsb2JhbAA8CcBiCBYOAQEBAQkJDQcSKYIfAQEEAScZARsdAQMBCwYFBAEGOyEBAREBBQEcBhOHfgEDCQahRow0gnuEXgoZJw1ZiHcBBQyMCoEFhEEDiGaLY4FYiz+DMRYphEQ X-IPAS-Result: AlQBALwFFFHRVYCtkWdsb2JhbAA8CcBiCBYOAQEBAQkJDQcSKYIfAQEEAScZARsdAQMBCwYFBAEGOyEBAREBBQEcBhOHfgEDCQahRow0gnuEXgoZJw1ZiHcBBQyMCoEFhEEDiGaLY4FYiz+DMRYphEQ X-IronPort-AV: E=Sophos;i="4.84,623,1355094000"; d="scan'208";a="1458572" Received: from mail-ve0-f173.google.com ([209.85.128.173]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Feb 2013 20:46:20 +0100 Received: by mail-ve0-f173.google.com with SMTP id oz10so2694264veb.4 for ; Thu, 07 Feb 2013 11:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=2demnEvlc/C3DqF07UG/0b/ujg25klhTzQXiK2W+Pwc=; b=nNFdHzj/E03FbIWpUvSz3zYcY9XNukM3u03Pmkw9s70EHt+6OGxhGw1CakO+XLlw6q OYjoKPKN8/VNkBwsQvyCn49ZQ1d7IyzstPm3/fWXZ2Vtd6I/nO1K95C1Y2n2xANKCVnE havouxtCHhvolidZH/wTtM3F0AO5uoy2fLxBzMdhz3pbIM8ep5/19C3Jqdn4QDmwIx9K c7rCRGvMK4uHJ7wKExxo6fFiEw+De12J+aiS3qFM4/99zKaWx8Ly81BfIWQrqcTvsYsO rW2qFWn+dG3HvWFSdvl0IuUm4Wx2Ryh3Ub7J5vT0MtV6Zm69CgIH3H6iUTH1oV9w7ZbU 0xpg== MIME-Version: 1.0 X-Received: by 10.220.40.9 with SMTP id i9mr3378354vce.23.1360266805249; Thu, 07 Feb 2013 11:53:25 -0800 (PST) Received: by 10.58.146.133 with HTTP; Thu, 7 Feb 2013 11:53:25 -0800 (PST) In-Reply-To: References: Date: Thu, 7 Feb 2013 11:53:25 -0800 Message-ID: From: Jeff Meister To: Ashish Agarwal Cc: Caml List Content-Type: multipart/alternative; boundary=bcaec54a3788ba048904d527cbdb Subject: Re: [Caml-list] use identity for default function --bcaec54a3788ba048904d527cbdb Content-Type: text/plain; charset=ISO-8859-1 Can't you simply define it this way? (I don't think I'm using any new features, so maybe I misunderstood your question.) OCaml version 4.00.1 # external id : 'a -> 'b = "%identity";; external id : 'a -> 'b = "%identity" # let foo ?(f = id) x = f x;; val foo : ?f:('a -> 'b) -> 'a -> 'b = On Thu, Feb 7, 2013 at 11:22 AM, Ashish Agarwal wrote: > 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 with > all the new features of OCaml? > > --bcaec54a3788ba048904d527cbdb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Can't you simply define it this way? (I don't thin= k I'm using any new features, so maybe I misunderstood your question.)<= br>
=A0=A0=A0=A0=A0=A0=A0 OCaml version 4.00.1

# external id : &#= 39;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 -&= gt; 'b =3D <fun>


On Thu, Feb 7, 2013 at 11:22 AM, Ashish Agarwal <agarwal1975@gmail.com= > wrote:
I'd like to implement

val foo : ?f:('a -> = 9;b) -> 'a -> 'b

where the default f= or f is identity. Is there now a way to do this with all the new features o= f OCaml?


--bcaec54a3788ba048904d527cbdb--