From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 56CAF81792 for ; Sun, 23 Jun 2013 09:15:37 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dra-news@metastack.com) identity=pra; client-ip=81.103.221.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="dra-news@metastack.com"; x-conformance=sidf_compatible Received-SPF: Neutral (mail3-smtp-sop.national.inria.fr: domain of dra-news@metastack.com does not assert whether or not 81.103.221.47 is permitted sender) identity=mailfrom; client-ip=81.103.221.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="dra-news@metastack.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@mtaout01-winn.ispmail.ntl.com) identity=helo; client-ip=81.103.221.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="postmaster@mtaout01-winn.ispmail.ntl.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsEAAFSgxlFRZ90vlGdsb2JhbABbgkV1wHoWDgEBAQEHDQkJFAMlgioIAh4FWQUWUiMcAQQeBYgCmSufTJM5A45wnSg X-IPAS-Result: AsEAAFSgxlFRZ90vlGdsb2JhbABbgkV1wHoWDgEBAQEHDQkJFAMlgioIAh4FWQUWUiMcAQQeBYgCmSufTJM5A45wnSg X-IronPort-AV: E=Sophos;i="4.87,922,1363129200"; d="scan'208,217";a="18674126" Received: from mtaout01-winn.ispmail.ntl.com ([81.103.221.47]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Jun 2013 09:15:36 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20130623071535.GSXT4711.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Sun, 23 Jun 2013 08:15:35 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20130623071535.FPCQ6472.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com> for ; Sun, 23 Jun 2013 08:15:35 +0100 Received: from Altus ([213.205.233.174]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id r5N7FPU9008381 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Sun, 23 Jun 2013 08:15:32 +0100 From: "David Allsopp" To: "OCaml List" Date: Sun, 23 Jun 2013 08:16:45 +0100 Organization: MetaStack Solutions Ltd. Message-ID: <001601ce6fe1$a2ea9390$e8bfbab0$@metastack.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0017_01CE6FEA.04B08230" X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac5v3yzwFRXNb/EAR2+F06vEU1G49Q== Content-Language: en-gb X-Scanned-By: MIMEDefang 2.65 on 172.16.0.20 X-Cloudmark-Analysis: v=1.1 cv=AUhbpHVS+xhHrj9wLCYAQoYnFLYUZdbP8UM0GmH2jwk= c=1 sm=0 a=cTs9vV391PwA:10 a=RQQLJnld3ZcA:10 a=hxoPgSqXykES2GFdPSMA:9 a=CjuIK1q_8ugA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=2ew1JDfXc2_RVSX0tRwA:9 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10 a=frz4AuCg-hUA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Subject: [Caml-list] Anonymous sum types in functors This is a multipart message in MIME format. ------=_NextPart_000_0017_01CE6FEA.04B08230 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I couldn't think of a better way to describe what I'm trying to do, so forgive the possibly strange subject! In: module IntSet = Set.Make(struct type t = int let compare = compare end) the resulting signature is: sig type elt = int type t ... but in: module FlagSet = Set.Make(struct type t = A | B let compare = compare end) the resulting signature is: sig type elt type t ... i.e. the constructors are hidden (I can see why, but presumably it is a special case in the type checker?) and the module is essentially useless. I don't want to define the type external to the module - the idea is that I'd be able to write Flag1Set.add Flag1Set.CommonFlag Flag1Set.empty and Flag2Set.add Flag2Set.CommonFlag Flag2Set.empty, etc. I can work around this by writing: module FlagSet = struct type flag = A | B include Set.Make(struct type t = flag let compare = compare end) end where the resulting signature is: sig type flag = A | B type elt = flag type t ... but I'm wondering: a) Is there a way to do it where you can end up with type elt = A | B (I think the answer is no?) b) Is there a syntactically lighter way to write the module definition? David ------=_NextPart_000_0017_01CE6FEA.04B08230 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I couldn't th= ink of a better way to describe what I'm trying to do, so forgive the possi= bly strange subject!

 

In:

 

module IntSet =3D Set.Make(struct = type t =3D int let compare =3D compare end)

 

the resulting signature= is:

 

sig

  type elt =3D = int

  type t

  ...

&n= bsp;

but in:

 

module FlagSet =3D Se= t.Make(struct type t =3D A | B let compare =3D compare end)

<= p class=3DMsoPlainText> 

the res= ulting signature is:

 

sig

&nbs= p; type elt

  type t<= /p>

  ...

 

i.e. the constructors are hid= den (I can see why, but presumably it is a special case in the type checker= ?) and the module is essentially useless. I don't want to define the type e= xternal to the module - the idea is that I'd be able to write Flag1Set.add = Flag1Set.CommonFlag Flag1Set.empty and Flag2Set.add Flag2Set.CommonFlag Fla= g2Set.empty, etc.

 

I can work around this by writing:

=

 

module= FlagSet =3D

  struct=

    type flag =3D A | B

    include Set.Make(struct ty= pe t =3D flag let compare =3D compare end)

  end

 

where the resulting signature is:

 

sig=

  type flag =3D A | B

=

  type elt =3D flag

  type t

  ...<= o:p>

 

but I'm wondering:

 = ;

a) Is there a way to do it where you can= end up with type elt =3D A | B (I think the answer is no?)

<= p class=3DMsoPlainText>b) Is there a syntactically lighter way to write the= module definition?

 =

 

Da= vid

= ------=_NextPart_000_0017_01CE6FEA.04B08230--