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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9DD717EEBF for ; Fri, 24 Jul 2015 16:25:53 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of bmillwood@janestreet.com) identity=pra; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of bmillwood@janestreet.com designates 38.105.200.112 as permitted sender) identity=mailfrom; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout1.mail.janestreet.com) identity=helo; client-ip=38.105.200.112; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="postmaster@mxout1.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DNAACvSbJVnHDIaSZcg2lpBqxhkFQBAYdEB0wBAQEBAQESAQEBAQEGFglPhDwRBBkBATgeAQY3AiQSAQUBIhsaiAwDqUKBLD4xik9whGUBBZEtARkGCpJ/DC8SgTGUaIR2h0aXWhIjgRUXhA1ugksBAQE X-IPAS-Result: A0DNAACvSbJVnHDIaSZcg2lpBqxhkFQBAYdEB0wBAQEBAQESAQEBAQEGFglPhDwRBBkBATgeAQY3AiQSAQUBIhsaiAwDqUKBLD4xik9whGUBBZEtARkGCpJ/DC8SgTGUaIR2h0aXWhIjgRUXhA1ugksBAQE X-IronPort-AV: E=Sophos;i="5.15,538,1432591200"; d="scan'208";a="141099034" Received: from mxout1.mail.janestreet.com ([38.105.200.112]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 24 Jul 2015 16:25:52 +0200 Received: from tot-qpr-mailcore1.delacy.com ([172.27.56.68] helo=tot-qpr-mailcore1) by mxout1.mail.janestreet.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1ZIdv5-00043z-2R for caml-list@inria.fr; Fri, 24 Jul 2015 10:25:51 -0400 X-JS-Flow: external Received: by tot-qpr-mailcore1 with JS-mailcore (0.1) (envelope-from ) id BVskrv-AAABGT-A-; 2015-07-24 10:25:51.031927-04:00 Received: from mail-qg0-f41.google.com ([209.85.192.41]) by mxgoog1.mail.janestreet.com with esmtps (UNKNOWN:AES128-GCM-SHA256:128) (Exim 4.72) (envelope-from ) id 1ZIdv4-0005aL-VN for caml-list@inria.fr; Fri, 24 Jul 2015 10:25:51 -0400 Received: by qgii95 with SMTP id i95so11280955qgi.2 for ; Fri, 24 Jul 2015 07:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:from:date:message-id:subject:to:content-type; bh=EnC4V5/vwMcRr3gxRcKa/DDzMrKV2EYpetvgP65P3mE=; b=bWlkBFK7zJyAks0I002+kMzWGU4/rcdvGoTlDDXTl8+yxfVm8i8KaNEyUYyR/JyePi GFUcdB8zb25vbsZg2rMo1J2dQe5itsEv8wxJMhDhSTviD5AgPwRtj24L+qSKVklRJmup qp1VP3WQqHzIE8W7miLbyWJTVFPdjSC+aUnr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=EnC4V5/vwMcRr3gxRcKa/DDzMrKV2EYpetvgP65P3mE=; b=YIEdNlzAtOvxxmxQsoM6QuL7po6wEY6Fg4SBU2G09s1vx9krpPxVgRcP5Z4bseUf86 g64EhN9HLlUqAn0M4zh2lmkS5NRVf8xQj4b66l+0/UdM4/94HP3WRRQxMcksY2sAlOZg h9/PPniSLG9BQHTdg2n+wLsC9QUJt3RDfwkM6RLoIKFT9NzD6rGwfJ+SvgOai3QzGJEa UlyBb5okuYRGoWap+YU0eEH0dkp2/J6Q4WgwUENSXT34qOVSgCfAmb8iWEw17XpBKqZk SLQ4ehlOaIHVKvWo2Y1ymVoD84dMEXwtsPZah8un0aZEX9lONTTnwX76fqbmYROJCpYW 2KQw== X-Gm-Message-State: ALoCoQlgXFNQ69E7LO2q3LThdGQ2gEF5bsTDlr8I3h85Dlx3h30qCSdR1AIL796vMUITywnjF0SuKEHR29zceBXO9V2RdiFh5z9w1d/N4cGoeTnzZl9wgkzzlhgl0G9A3swRokPdw98l X-Received: by 10.140.202.84 with SMTP id x81mr21813428qha.50.1437747950730; Fri, 24 Jul 2015 07:25:50 -0700 (PDT) X-Received: by 10.140.202.84 with SMTP id x81mr21813415qha.50.1437747950586; Fri, 24 Jul 2015 07:25:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.96.142.106 with HTTP; Fri, 24 Jul 2015 07:25:31 -0700 (PDT) From:Ben Millwood Date: Fri, 24 Jul 2015 15:25:31 +0100 Message-ID: To:caml users Content-Type: multipart/alternative; boundary=001a1141b5a0df4e58051b9fc786 X-JS-Processed-by: mailcore Subject: [Caml-list] Can we have more flexible destructive type substitution? --001a1141b5a0df4e58051b9fc786 Content-Type: text/plain; charset=UTF-8 Currently, for [sig ... end with type lhs := rhs] to be valid, rhs needs to be an application of a type constructor to the same type parameters as lhs. I'd like to do, at a minimum, [sig ... end with type 'a t := 'a], but this is currently forbidden. Are there conceptual obstacles to permitting arbitrary type expressions on the RHS, or are they simply not implemented yet? Note that I can do [type 'a id = 'a] and then [... with type 'a t := 'a id], but it's clumsy to have to define an auxiliary type for this and it's not always easy to find an appropriate place to do so. In particular, I have modules with a blocking interface and an Async interface, so I define: module type Thing = sig type 'a result val read_thing : in_channel -> thing result val write_thing : out_channel -> unit result end thing_async.mli: include Thing with type 'a result := 'a Deferred.t thing_or_error.mli: include Thing with type 'a result := 'a Or_error.t thing_exn.mli: include Thing with type 'a result := 'a (* fails :( *) Having Thing_exn.id be a useless type constructor would be pretty sad. --001a1141b5a0df4e58051b9fc786 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Currently, for [sig ... end with type lhs :=3D rhs] to be = valid, rhs needs to be an application of a type constructor to the same typ= e parameters as lhs.

I'd like to do, at a minimum, [= sig ... end with type 'a t :=3D 'a], but this is currently forbidde= n. Are there conceptual obstacles to permitting arbitrary type expressions = on the RHS, or are they simply not implemented yet?

Note that I can do [type 'a id =3D 'a] and then [... with type &#= 39;a t :=3D 'a id], but it's clumsy to have to define an auxiliary = type for this and it's not always easy to find an appropriate place to = do so.

In particular, I have modules with a blocki= ng interface and an Async interface, so I define:

= module type Thing =3D sig
=C2=A0 type 'a result
=C2= =A0 val read_thing : in_channel -> thing result
=C2=A0 val wri= te_thing : out_channel -> unit result
end

=
thing_async.mli:
include Thing with type 'a result :=3D = 'a Deferred.t
thing_or_error.mli:
include Thing wit= h type 'a result :=3D 'a Or_error.t
thing_exn.mli:
<= div>include Thing with type 'a result :=3D 'a (* fails :( *)<= div>
Having Thing_exn.id be a useless type constructor would = be pretty sad.
--001a1141b5a0df4e58051b9fc786--