From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 9821F5D4 for ; Wed, 26 Feb 2020 18:37:55 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.70,489,1574118000"; d="scan'208,217";a="437792876" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 26 Feb 2020 19:37:54 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 837007F438; Wed, 26 Feb 2020 19:37:54 +0100 (CET) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id B773A7ED20 for ; Wed, 26 Feb 2020 19:37:47 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=octa@polychoron.fr; spf=Pass smtp.mailfrom=octa@polychoron.fr; spf=Pass smtp.helo=postmaster@quaesituri.org IronPort-PHdr: =?us-ascii?q?9a23=3Ah6zjghcqc31Qvms6gDUI4M3PlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcu/bB7h7PlgxGXEQZ/co6odzbaP7+axBSdZuMvJmUtBWaIPfidNsd?= =?us-ascii?q?8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3wOgVv?= =?us-ascii?q?O+v6BJPZgdip2OCu4Z3TZBhDiCagbb9oIxi6sArcutMSjIZtJao91wbFr3tVcO?= =?us-ascii?q?lK2G1kIk6ekBn76sqs5pBo7j5eu+gm985OUKX6e7o3QLlFBzk4MG47+dPmuwDb?= =?us-ascii?q?QQSA+nUTXGMWkgFVAwfe9xH1Qo3xsirhueVj3iSRIND7Qqo1WTSm6KdrVQPohS?= =?us-ascii?q?IaPDM37G3blsp9h79drRm8pRJw3pTUbZmVOvRjYK3dc9AUS2RPUcleVSNOHpix?= =?us-ascii?q?YJETA+cbJ+tUs4fwqlkIoBCjBQesHuTvyjpQi3H22a061P4hEQDc0wwmAtkDrH?= =?us-ascii?q?LUrNrrO6cWT++10LXIzTTeZP5R3jfy9JTIfQo6rPGUWrJwdcrQxlUvFwPClFWQ?= =?us-ascii?q?rorlMymb1uQXqmWW6fdrW+yoi24isQ5xoz6vy98jionImoIVyk3E+j5jzIkpIt?= =?us-ascii?q?24TUh2asOnHptIryyXN5F6Tt4mTmxpoio3yKcKtJ6mcCQSzJkr2QTTZ+GGfoWG?= =?us-ascii?q?+B7vSuecLS15iX9qfr+0mgy8/lK6yuLmU8m5yFZKoTRBktnLrn0NzgHT5dKZRf?= =?us-ascii?q?tm/0ehxSuP1xrS6u1eJkA0j6XbJ4Ygwr42iJUTrVzOEy/slEnriKKbd18o9+qy?= =?us-ascii?q?5+nnf7nqvpqcOJV1igH6PKQugMu/AeEgPwgJQ2eb5f6z2ab7/U3+RLVLjuE5kq?= =?us-ascii?q?nesJDAIsQboLS1AwFP0oo78RawEy+m0MgEnXkANF9KZAiIj43tO13XJPD4DOy/?= =?us-ascii?q?g0i3nTdwx/HGO6XhDY/XInjClrfhZ7d95FRGxAo919AMr65TX7oIJfa2Xk7qqP?= =?us-ascii?q?TZCAU4Okq62bXJEtJ4g60aXniOC6nRGaXdvFuF+v4ua72Lb5MckC76L+ku5/n0?= =?us-ascii?q?inl/l0VLLvrh5ocedH3tRqcuGE6ee3e52o5cQ1dPhRI3SanRsHPHUTNXYC/sDb?= =?us-ascii?q?sh7zwgCZ67F4aFQZqi0uXYjXWLW6ZOb2UDMWiiVHLhdoGKQfAJMX/AOshlgzcE?= =?us-ascii?q?UqKmTckvz0P37VOo+/9cNuPRvxYgm9f7ztEsur/LkhUj/jxzFcOblW+XHTl5?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0C1DwD/uVZe/zMHxAVcCh+CJIInbANSM?= =?us-ascii?q?iqEFI56TgEBAQEBAQaBEoQThgOLZIVoCQEDAQwjCQECBAEBhEACCIF5HQYBBDU?= =?us-ascii?q?FDQIQAQEFAQEBAgECAwQBbIU3DII7IoMHBiMdAQE4DwsEPgICVxMIAQGDIgGCV?= =?us-ascii?q?ikLr1GBMoJ/AQEFgS8BgRSEaQMGgTiMJRp5gQeBOAyCMi4+gmQCgTh6gkSCXrA?= =?us-ascii?q?agUh+h1GPDiKPC4wjlW6BfpJzgWohgVhNJxE7gmxQGA2SEIUUhUJAM4EEAZBZA?= =?us-ascii?q?QE?= X-IPAS-Result: =?us-ascii?q?A0C1DwD/uVZe/zMHxAVcCh+CJIInbANSMiqEFI56TgEBAQE?= =?us-ascii?q?BAQaBEoQThgOLZIVoCQEDAQwjCQECBAEBhEACCIF5HQYBBDUFDQIQAQEFAQEBA?= =?us-ascii?q?gECAwQBbIU3DII7IoMHBiMdAQE4DwsEPgICVxMIAQGDIgGCVikLr1GBMoJ/AQE?= =?us-ascii?q?FgS8BgRSEaQMGgTiMJRp5gQeBOAyCMi4+gmQCgTh6gkSCXrAagUh+h1GPDiKPC?= =?us-ascii?q?4wjlW6BfpJzgWohgVhNJxE7gmxQGA2SEIUUhUJAM4EEAZBZAQE?= X-IronPort-AV: E=Sophos;i="5.70,489,1574118000"; d="scan'208,217";a="437792859" X-MGA-submission: =?us-ascii?q?MDHywQE+jzag6FLFGnupHWg43ciaLzk0nQm1ah?= =?us-ascii?q?YNW/OVRxNr1qm0YYkCtDMaCYup5UH91Mbd69lzFygTrVNO0JyXMQnPCH?= =?us-ascii?q?ruNQ7MPFKgC/T93WLmdzouN3tss9IDKVFdN2dmkE/S2bcB30tETRSCSk?= =?us-ascii?q?WHsgPIixE8NqVc0i7R+BXLPg=3D=3D?= Received: from quaesituri.org ([5.196.7.51]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2020 19:37:47 +0100 Received: from [192.168.1.202] (unknown [92.163.26.64]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by quaesituri.org (Postfix) with ESMTPSA id E874410EEF9 for ; Wed, 26 Feb 2020 19:38:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.quaesituri.org; s=mail; t=1582742304; bh=ZKcy7H3W7avPQGBRfmgKGdGn3PBCCjXVc3JmErXH3K8=; h=From:Subject:To:References:Date:In-Reply-To; b=QzNY3/EjJjkzRyb81cWkssjjyQuyMKICbC+J9jAF1tSoI68Nn4NVAMPbHylSZdZ4s tym+f4sEU8PwMge5seycWblMc6EZdYQFzovUNQbVoKbrAJ0Ohpoghs88F0rH+FTcln 87IW9lSe11kVALMLHpfl1jWdoorZnSuYvsSOW54g= From: Florian Angeletti To: caml-list@inria.fr References: <877e09fjs7.fsf@port-garion.isae.fr> Message-ID: <83871ab5-6859-c684-9457-81fb847147df@polychoron.fr> Date: Wed, 26 Feb 2020 19:36:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <877e09fjs7.fsf@port-garion.isae.fr> Content-Type: multipart/alternative; boundary="------------98E23B95DE51F24917EE8716" Content-Language: en-US Subject: Re: [Caml-list] Printer for lists in toplevel is different when opening List Reply-To: Florian Angeletti X-Loop: caml-list@inria.fr X-Sequence: 18021 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This is a multi-part message in MIME format. --------------98E23B95DE51F24917EE8716 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit The printer for lists is indeed quite sensitive to the exact path of the type being printed. Any manipulation that muddles this path makes the printer revert to the generic sum type printer. Moreover, in the case of `List`, the list type is re-exported as type |'a| t =|'a list| = | [] | (::) of 'a * 'a list Thus after opening the List module, the toplevel printer sees 1 :: (2 :: ...) as ( 1 :: (2 :: ... : 'a list) : 'a t) And since t is different that list, it prints the value as (::)(1, ...) then starting from the second element, we are back to 'a list and the pretty list printer. This means that we can make the situation worse by re-exporting the type list as type |'a| t =|'a list| = | [] | (::) of 'a * 'a t With this definition, we completely confuse the pretty printer for lists and are rewarded with: # [1;2];; - : int t = (::) (1, (::) (2, [])) If you are interested, I have a small patch that makes the toplevel printer identify the list type more reliably: https://github.com/ocaml/ocaml/pull/9336 . — octachron. --------------98E23B95DE51F24917EE8716 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

The printer for lists is indeed quite sensitive to the exact path of the type being printed.

Any manipulation that muddles this path makes the printer revert to the generic sum type printer.

Moreover, in the case of `List`, the list type is re-exported as

type 'a t = 'a list = 
| []
| (::) of 'a * 'a list

Thus after opening the List module, the toplevel printer sees

1 :: (2 :: ...)

as

( 1 :: (2 :: ... : 'a list) : 'a t)

And since t is different that list, it prints the value as

(::)(1, ...)

then starting from the second element, we are back to 'a list and the pretty list printer.

This means that we can make the situation worse by re-exporting the type list as

type 'a t = 'a list = 
| []
| (::) of 'a * 'a t

With this definition, we completely confuse the pretty printer for lists and are rewarded with:

# [1;2];;
- : int t = (::) (1, (::) (2, []))

If you are interested, I have a small patch that makes the toplevel printer identify the list type more reliably: https://github.com/ocaml/ocaml/pull/9336 .

— octachron.

--------------98E23B95DE51F24917EE8716--