From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=2.0 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 3C73CBC37 for ; Mon, 12 Oct 2009 00:16:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At0CAIb10UrRVdPGi2dsb2JhbACRRokIPwEBAQoLCgcRBapzgTqEeYhlAQMDBYQoBA X-IronPort-AV: E=Sophos;i="4.44,543,1249250400"; d="scan'208";a="38027528" Received: from mail-yw0-f198.google.com ([209.85.211.198]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Oct 2009 00:16:12 +0200 Received: by ywh36 with SMTP id 36so8753961ywh.15 for ; Sun, 11 Oct 2009 15:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=1um6Pa2ICljOqY7HcVhoKurCjhRWODZsRa9L7R9P4d4=; b=obww46USUwnidn43rzkxTX+yrIOd0KT6L4RwjdtZ0Zb2qDyrdoq0x8x8bpbh6zlKVt vY8UCuldO0vtKw+kiiroWmSYQnOGn17b4YN4yBsAu06GW/7en6NVk8QSV2b0srIr0CUY OYMZOsIC3Do8oZ99gHky4S3uJZb7IcBr6cFUM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=YMQM0veQRJoaTQbcdlnahQSFGWMwucY5BKPh7tQfK4Q3dRtSUbmsDqReS/GFybfKAG GlAqZdX6RdVpBC8/c2MBLH6bsqjtlvEumoXxDlkjlxKmakXRGjO5xI00nqtgDQgFdURE FrRAG2/EZQSjfRb6xFxv4VkF/vKXHJ4aMfkaQ= MIME-Version: 1.0 Received: by 10.101.102.16 with SMTP id e16mr4969909anm.84.1255299371745; Sun, 11 Oct 2009 15:16:11 -0700 (PDT) In-Reply-To: <605bf2750910111446m2d4b91cawf4dbadeed1b6ae88@mail.gmail.com> References: <891bd3390910081840p37e8c786g60b2c15d2c06ae60@mail.gmail.com> <891bd3390910081853m5409c871y35495c6f16e180aa@mail.gmail.com> <5160b4200910110757y47ffad15v70434418cba61f26@mail.gmail.com> <62B782AA-1F44-4207-B037-5C6D1F6CBF50@gmail.com> <5160b4200910110824q7998f43ao3d00e94ba7e74b2b@mail.gmail.com> <605bf2750910111257h1b2b3f31me95be82ba73b65a3@mail.gmail.com> <200910112317152031791@orange.fr> <605bf2750910111446m2d4b91cawf4dbadeed1b6ae88@mail.gmail.com> Date: Mon, 12 Oct 2009 00:16:11 +0200 Message-ID: <4a708d20910111516j2d19282bveb300ad1810d06f2@mail.gmail.com> Subject: Re: [Caml-list] Improving OCaml's choice of type to display From: Lukasz Stafiniak To: Gilles Pirio Cc: "caml-list@yquem.inria.fr" Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; ocaml's:01 lukasz:01 val:01 compiler:01 arity:01 ocaml:01 damien:01 mismatch:01 ocaml:01 val:01 2009:98 beginners:01 wrote:01 caml-list:01 functions:01 You need to use a type alias: # type ('a, 'b) func = 'a -> 'b;; type ('a, 'b) func = 'a -> 'b # let castro a = (fun _ -> a : ('a,'b) func);; val castro : 'a -> ('b, 'a) func = This is also how the compiler decides the arity of C functions from "external" declarations, that is, it "counts the arrows" without unfolding type aliases. On Sun, Oct 11, 2009 at 11:46 PM, Gilles Pirio wrote: > Hey Damien > > Sure, I fully understand that both types are equivalent given the rules > governing the application operator. My point was more on the usability side, > as the type display is primarily intended at helping the programmer to > quickly figure out type mismatch. So I'd think having a display allowing to > quickly distinguish between the noe and castro functions below would be a > good thing, especially for beginners. I've been using ocaml for a few years > now, and I have to say that it's not a major issue any more - just wanted to > give some feedback about this. > > Thanks > Gilles > > > # let noe a b = a;; > val noe : 'a -> 'b -> 'a = > # let castro a = fun _ -> a;; > val castro : 'a -> 'b -> 'a = >