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 sympa.inria.fr (Postfix) with ESMTPS id E9D9BE0035 for ; Mon, 13 Sep 2021 14:22:06 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=oleg@okmij.org; spf=Pass smtp.mailfrom=oleg@okmij.org; spf=None smtp.helo=postmaster@mail1.g3.pair.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of oleg@okmij.org) identity=pra; client-ip=66.39.3.114; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="oleg@okmij.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of oleg@okmij.org designates 66.39.3.114 as permitted sender) identity=mailfrom; client-ip=66.39.3.114; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="oleg@okmij.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail1.g3.pair.com) identity=helo; client-ip=66.39.3.114; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="oleg@okmij.org"; x-sender="postmaster@mail1.g3.pair.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?A9a23=3AUndKMhNIUJl0XqRtWvMl6nYrDRdPi9zP1u491JM?= =?us-ascii?q?rhvp0f7i5+Ny6ZQqDv60r3QaCANqTwskHotKei7rnV20E7MTJm1E5W7sIaSU4j?= =?us-ascii?q?94LlRcrGs+PBB6zBvfraysnAJYKDwc9rDm0PkdPBcnxeUDZrGGs4j4OABX/Mhd?= =?us-ascii?q?+KvjoFoLIgMm7yfy+94fXbglVizawYbF/JwiqoAvMscUbnZFsIbsrxBvTpXtId?= =?us-ascii?q?eVWxWd2Kl+Wgh3x+MS+8oN9/ipJo/4u+NJO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?= =?us-ascii?q?=3D=3D?= IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AGh2RWalXQr5HwnnMiT8bUUA72TbpDfIu3DAb?= =?us-ascii?q?v31ZSRFFG/Fw5Pre5cjztCWE7gr5N0tQ++xoVJPgfZqYz+8T3WBzB8bHYOCFgh?= =?us-ascii?q?rKEGgK1+KLqFeMJ8S9zIFgPMxbH5SWZuefMbE3t7ee3OHkfuxB/OW6?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DUAACYahphmHIDJ0JaHgEBCxIMQIR7V?= =?us-ascii?q?wE5MY1LhkWCJJ1nCwEDAQ01CgIEAQGHTgIdBwEENBMBAgQVAQEFAQEBAgEDAwQ?= =?us-ascii?q?BEwEBAQEBAQEBCQsQBjokhTsIJQ2CNSKELDOBAYNNAYMGAQ+naoEzgQGKGoE6j?= =?us-ascii?q?hoPDYFIRYQ6gwkXA4IsgwCCLgSEKoEiATBWFmihCZxqM4MygUKBUocpk3tFhS2?= =?us-ascii?q?BN6ARok+ZB4F3gX1NMAg7gmkJRxkOiVuEXohthVkyATE4AgYLAQEDCWuJCgEB?= X-IPAS-Result: =?us-ascii?q?A0DUAACYahphmHIDJ0JaHgEBCxIMQIR7VwE5MY1LhkWCJJ1?= =?us-ascii?q?nCwEDAQ01CgIEAQGHTgIdBwEENBMBAgQVAQEFAQEBAgEDAwQBEwEBAQEBAQEBC?= =?us-ascii?q?QsQBjokhTsIJQ2CNSKELDOBAYNNAYMGAQ+naoEzgQGKGoE6jhoPDYFIRYQ6gwk?= =?us-ascii?q?XA4IsgwCCLgSEKoEiATBWFmihCZxqM4MygUKBUocpk3tFhS2BN6ARok+ZB4F3g?= =?us-ascii?q?X1NMAg7gmkJRxkOiVuEXohthVkyATE4AgYLAQEDCWuJCgEB?= X-IronPort-AV: E=Sophos;i="5.84,326,1620684000"; d="scan'208";a="528141754" X-MGA-submission: =?us-ascii?q?MDEIs7TdX7mrx16ntaxjuYWdqShy2Ub00wqvwW?= =?us-ascii?q?9JwkKasHEnjjVgsGtTDgtC8wL16tToieTJV/VBHO/Z99ssEqJHeJIBe5?= =?us-ascii?q?qhGGQUIkE71bWHRv6nui9PlqCF0/rFsmx31IG0q2ncFuKQASfzXy9+NJ?= =?us-ascii?q?xlGqdP+dC7YU0htty2pPU6Cg=3D=3D?= Received: from mail1.g3.pair.com ([66.39.3.114]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2021 14:22:05 +0200 Received: from mail1.g3.pair.com (localhost [127.0.0.1]) by mail1.g3.pair.com (Postfix) with ESMTP id 3F4843FB4A9; Mon, 13 Sep 2021 08:22:03 -0400 (EDT) Received: from Melchior.localnet (118.6.138.210.rev.vmobile.jp [210.138.6.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail1.g3.pair.com (Postfix) with ESMTPSA id 90CC3583791; Mon, 13 Sep 2021 08:22:01 -0400 (EDT) Date: Mon, 13 Sep 2021 21:21:39 +0900 From: Oleg To: caml-list@inria.fr Message-ID: <20210913122139.GA3696@Melchior.localnet> Mail-Followup-To: Oleg , caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Subject: [Caml-list] Higher-kinded bounded polymorphism Abstraction over polymorphic types is something that one comes across from time to time, especially when implementing operations generic over collections, or embedding typed DSLs (particularly in tagless-final style). One immediately learns that OCaml does not have higher-kinded type variables (type variables that range over type constructors like list and array); does not permit type constructors appearing by themselves, without being applied to the right number of arguments; and restricts polymorphic types in other ways (e.g., not allowing them in type constraints of package types). One soon learns that the module system (using functors) is a way to realize higher-kinded polymorphism in OCaml. It takes longer to learn it is not the only way, however. The following web page is written to speed up this learning. It collects what I have learned and rediscovered on this topic, arranged into a single story and with new explanations and attributions (and occasionally, new variations). http://okmij.org/ftp/ML/higher-kind-poly.html One interesting discovery is that some problems that ostensibly require higher-kinded polymorphism really do not. The article comes with the complete accompanying code.