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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id C31D17EEDB for ; Sat, 27 Oct 2012 15:51:58 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.115; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.115 as permitted sender) identity=mailfrom; client-ip=38.105.200.115; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@nyc-dmz-mxout2.janestreet.com) identity=helo; client-ip=38.105.200.115; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@nyc-dmz-mxout2.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQBAKTmi1Amachzl2dsb2JhbABEwlQrAQEBAQEIFgc7gjcCExkBATglXRIBBQEjGhqHZAOdJWIJA4pzhDMBBY5wBpJSlXeOXhYphC2BfQ X-IronPort-AV: E=Sophos;i="4.80,661,1344204000"; d="scan'208";a="160608595" Received: from mx2.janestreet.com (HELO nyc-dmz-mxout2.janestreet.com) ([38.105.200.115]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Oct 2012 15:51:57 +0200 Received: from nyc-qsv-mail1.delacy.com ([172.25.22.57]) by nyc-dmz-mxout2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1TS6nr-0007qR-9b for caml-list@inria.fr; Sat, 27 Oct 2012 09:51:55 -0400 Received: from nyc-dmz-mxgoog1.delacy.com ([172.25.224.109] helo=mxgoog1.janestreet.com) by nyc-qsv-mail1.delacy.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1TS6nr-0004ty-8E for caml-list@inria.fr; Sat, 27 Oct 2012 09:51:55 -0400 Received: from mail-qc0-f198.google.com ([209.85.216.198]) by mxgoog1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1TS6nr-0008WL-5X for caml-list@inria.fr; Sat, 27 Oct 2012 09:51:55 -0400 Received: by mail-qc0-f198.google.com with SMTP id e13so7884153qcs.9 for ; Sat, 27 Oct 2012 06:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:x-originating-ip:date:message-id:subject:from:to :content-type; bh=mxP0L6vfa59x0wmCOwmDZehqnY/FfxH/zb73VgwowFI=; b=i7ixg2QguAzKa6KwfSyqvKtfC44VjCjFRaa5Vtj/nxv9vl5Ku5B/sEOpnS1hzuuhSU S6kT8Hfc6VxhEXoXjBHp2bUu8wJPTQqrI1YXt8B+3gWng4YGIsRWUwJ22u7q9rQ4mxEC o0ZykEOmY2Xa2GY7EA/rL3WYko0BBCr/5/xLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=mxP0L6vfa59x0wmCOwmDZehqnY/FfxH/zb73VgwowFI=; b=Q3BVrULe34yFpjZxfFZEpM1f/kNIt6mOZqUgpYfuat1jugfR9UjxMDBy+LfLlN5Q++ kuegUtA8QJlZOmtiUVxluB7GNTQVbZcYPDaoSeGvy15wGe2e3tOF6KIdNFxSpS5hmiA3 0HFZyAyOVuIkYZnrIOzln88G5xF2gjRwGyLQtmaOBmk8rH5C6glSMYkhRNhHzJK8Hz0w 2UM1NU5ZAC0DSIInE8Ciqo16uvW8cu46JlJK0qx2/uoGM8JYOFjM5AvD4Fe/O+dBoP1+ +DTYA5+aq+670WkXxXrp+Y1L5vUpnvZmvR84wPE9jdQA3jDs5/PI8OIBX9aDsaoLxVln fcQg== Received: by 10.58.2.104 with SMTP id 8mr45143960vet.48.1351345914946; Sat, 27 Oct 2012 06:51:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.2.104 with SMTP id 8mr45143956vet.48.1351345914848; Sat, 27 Oct 2012 06:51:54 -0700 (PDT) Received: by 10.58.203.225 with HTTP; Sat, 27 Oct 2012 06:51:54 -0700 (PDT) X-Originating-IP: [72.225.238.212] Date: Sat, 27 Oct 2012 09:51:54 -0400 Message-ID: From: Yaron Minsky To: ocaml-core@googlegroups.com, caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQnxFK76WOsu4kCUvrJEwTTbyp6OpMC4BzKQf0DMDBHhsW7aGHmKxvFwWYEvcVKREdghw2j5phC8RibXOlNeBW0+L/Hjvyf13rKKI7xrvuoXt5xYDp6ZaoO8faXtPCtg4VjcMAwN1YefZE3bTZMipRtmOYUuqw== Subject: [Caml-list] short-types patch If you use Core or Async, you may have been frustrated by the way that OCaml reports types, both in the toplevel and, more importantly, in error messages. Here's a mildly contrived example. let f l x = List.Assoc.add l (Int.of_string x) (String.to_list x) |! List.Assoc.map ~f:(fun x -> List.filter_map x ~f:(fun c -> if Char.is_alpha c then Some (String.of_char c) else None)) If you run this through the toplevel, you'll get the following monstrous type. val f : (Core.Std.Int.t, Core.Std.Char.t Core.Std.List.t) Core.Std.List.Assoc.t -> Core.Std.String.t -> (Core.Std.Int.t, Core.Std.String.t Core.Std.List.t) Core.Std.List.Assoc.t = As you can see, the inferred types are a little ugly. Happily, Jacques Garrigue wrote a patch to improve this, which you can now try out in OPAM by typing: opam switch 4.00.1+short-types Now, if you try the same thing, you get something far easier to read: val f : (int, char list) List.Assoc.t -> string -> (int, string list) List.Assoc.t = The basic heuristic is that OCaml looks at all of the different names for a given type that it learns about during the inference process, and among those, it displays the one with the fewest number of dots, and among those with the minimal number of dots, it picks the most recent definition. Please try it out, and report any problems you run into! y