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 2F1EF7FC86 for ; Thu, 19 Mar 2015 02:27:51 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of milanst@gmail.com) identity=pra; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of milanst@gmail.com designates 209.85.213.171 as permitted sender) identity=mailfrom; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; 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@mail-ig0-f171.google.com) identity=helo; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="postmaster@mail-ig0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CyAAC9JQpVlKvVVdFcg1haBIMJwxSFcwKBUQdMAQEBAQEBEQEBAQEHCwsJEjCEEAEBBBIRBBkBGx0BAwwGBQsNAgImAgIiAREBBQEcBhMih3gBAxENpT4+MYsxgWuCd5BvChknDVSEXAEBAQEGAQEBAQEXAQUOgROJdoJqAYFTMweCaIFFBZQ0hX+BVYwrBYRXEiOBDAmELCIxgkMBAQE X-IPAS-Result: A0CyAAC9JQpVlKvVVdFcg1haBIMJwxSFcwKBUQdMAQEBAQEBEQEBAQEHCwsJEjCEEAEBBBIRBBkBGx0BAwwGBQsNAgImAgIiAREBBQEcBhMih3gBAxENpT4+MYsxgWuCd5BvChknDVSEXAEBAQEGAQEBAQEXAQUOgROJdoJqAYFTMweCaIFFBZQ0hX+BVYwrBYRXEiOBDAmELCIxgkMBAQE X-IronPort-AV: E=Sophos;i="5.11,426,1422918000"; d="scan'208";a="126655075" Received: from mail-ig0-f171.google.com ([209.85.213.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 19 Mar 2015 02:27:50 +0100 Received: by igbqf9 with SMTP id qf9so10023930igb.1 for ; Wed, 18 Mar 2015 18:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=EkX+PkbbrpBQ3Mt2V143uPHncHD1Bmn7eos5ZlG5XlU=; b=LUOXBM9HtSdrCoPzsGpwR3g+5c5BUKiMMdFUWX7+ZJLbQlBS0fGk2bRWfvmJDt5j8+ 1UsEvXlQeROyrDX0ks3AHI2U+jf9y+AIVfhK+ciLh1yyBfAitCoPcg8lGN06tUN8Jv7R eXqXATHkPdP5F0b/Hjq18xmaItSg31ohZlh1kx9SQJmGOzwxKNujCuKrLaOR6Ew6GZAY m+s5UZgR5UTRS7x1iqZamrUfnMbMO7y5G6Dcaczlk3P34N/Z/vITeA7CjQL9NOFP61HU x8RGki0ffOuotU6RZDLT280H7z3k0lToUEMhD+doACJcRPNqWI+m1AYiuqcvXXWa/p2n RQWw== X-Received: by 10.50.111.168 with SMTP id ij8mr12088538igb.43.1426728469371; Wed, 18 Mar 2015 18:27:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.154.134 with HTTP; Wed, 18 Mar 2015 18:27:09 -0700 (PDT) In-Reply-To: <596DAEC11B474882835CEA10AAACE35E@erratique.ch> References: <2AB388B4D07D4DDABA30298A7C890319@erratique.ch> <596DAEC11B474882835CEA10AAACE35E@erratique.ch> From: =?UTF-8?Q?Milan_Stanojevi=C4=87?= Date: Wed, 18 Mar 2015 21:27:09 -0400 Message-ID: To: =?UTF-8?Q?Daniel_B=C3=BCnzli?= Cc: Caml-list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] GADT existential escape This is doable in OCaml. Core has one possible implementation. https://github.com/janestreet/core_kernel/blob/master/lib/type_equal.mli#L1= 71 type 'a key =3D 'a Type_equal.Id.t let lookup dict key =3D List.find_map disct ~f:(function | B (key', a) -> match Type_equal.Id.same_witness key key' with | None -> None | Some T -> Some a) ;; You can also check out Univ and Univ_map modules in Core. Note that Univ was possible in OCaml even before first-class modules, GADTs and extensible types (which are all used in Type_equal) https://blogs.janestreet.com/a-universal-type/ On Wed, Mar 18, 2015 at 9:07 PM, Daniel B=C3=BCnzli wrote: > Le jeudi, 19 mars 2015 =C3=A0 01:39, Milan Stanojevi=C4=87 a =C3=A9crit : >> Can you give some hypothetical example code ? > type 'a key =3D ? > type binding =3D B : 'a key * 'a -> binding > type dict =3D binding list > let lookup : dict -> 'a key -> 'a option =3D fun d k -> ? > > Is it possible to specify a `'a key` type that allows `lookup` (with the = obvious semantics) to be written ? This is trivial to achieve with a univer= sal type, see http://mlton.org/PropertyList > > Best, > > Daniel > >