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 5AACA7F20B for ; Thu, 7 Feb 2013 21:06:21 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of kerneis@pps.jussieu.fr) identity=pra; client-ip=213.186.56.95; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel@kerneis.info"; x-sender="kerneis@pps.jussieu.fr"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel@kerneis.info designates 213.186.56.95 as permitted sender) identity=mailfrom; client-ip=213.186.56.95; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel@kerneis.info"; x-sender="gabriel@kerneis.info"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@witko.kerneis.info designates 213.186.56.95 as permitted sender) identity=helo; client-ip=213.186.56.95; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel@kerneis.info"; x-sender="postmaster@witko.kerneis.info"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlUFAGcIFFHVujhf/2dsb2JhbAA8CYYCAUa6IRZzgh8BAQUjBAsBDQEBNwEPCw4KAgIFEw4CAg8FKCGIKKw7cYNKAQWPAAaBI4t4gy4yYZYjhWWKboMB X-IPAS-Result: AlUFAGcIFFHVujhf/2dsb2JhbAA8CYYCAUa6IRZzgh8BAQUjBAsBDQEBNwEPCw4KAgIFEw4CAg8FKCGIKKw7cYNKAQWPAAaBI4t4gy4yYZYjhWWKboMB X-IronPort-AV: E=Sophos;i="4.84,623,1355094000"; d="scan'208";a="1459675" Received: from witko.kerneis.info ([213.186.56.95]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 07 Feb 2013 20:59:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kerneis.info; s=witko-rsa1; h=Subject:In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID:Cc:To:From:Date; bh=2G9AcWi3MA4U27HEPnj/hAFaZ8r48BX3zR/KnsyzlEc=; b=JblWZ8CbE4jOgojQGeI2oXS4ZE5TIWk5zi4MVZ3/ZxQI0QcaQUiszwvLsl7YjxuAwy6sdHAU4Vqkm2ge4onWh71KsKHZBAoD6E0xFl7P8iBCkU5arNYS26dtEWiJ/iEo; Received: from gabriel by witko.kerneis.info with local (Exim 4.72) (envelope-from ) id 1U3Xjf-0008G5-TB; Thu, 07 Feb 2013 21:06:20 +0100 Date: Thu, 7 Feb 2013 21:06:19 +0100 From: Gabriel Kerneis To: Jeff Meister Cc: Ashish Agarwal , Caml List Message-ID: <20130207200619.GA28009@kerneis.info> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: gabriel@kerneis.info X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on witko.kerneis.info X-Spam-Level: X-SA-Exim-Version: 4.2.1 (built Mon, 22 Mar 2010 06:51:10 +0000) X-SA-Exim-Scanned: Yes (on witko.kerneis.info) Subject: Re: [Caml-list] use identity for default function On Thu, Feb 07, 2013 at 11:53:25AM -0800, Jeff Meister wrote: > Can't you simply define it this way? > # external id : 'a -> 'b = "%identity";; > # let foo ?(f = id) x = f x;; If using unsafe features is okay, you might do even shorter: # let foo ?(f = Obj.magic) x = f x ;; val foo : ?f:('a -> 'b) -> 'a -> 'b = But remember that “Obj.magic is not part of the language”! For some good reason: # let x : int list = foo 0;; val x : int list = [] -- Gabriel