caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: David Allsopp <dra-news@metastack.com>
Cc: "OCaml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Anonymous sum types in functors
Date: Mon, 24 Jun 2013 08:15:38 +0900	[thread overview]
Message-ID: <FE6DC106-80C6-4E4B-B8AE-2F97DC90A950@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <001601ce6fe1$a2ea9390$e8bfbab0$@metastack.com>

On 2013/06/23, at 16:16, David Allsopp <dra-news@metastack.com> wrote:

> module FlagSet = Set.Make(struct type t = A | B let compare = compare end)
[doesn't work]
> 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?)

Xavier described the official solution.
However, since 3.12 you can also do some trickery.
This is going to be heavier, so this is probably a bad idea, but if you really need it, here it is:

module FlagSet = struct
  type elt = A | B
  include (Set.Make (struct type t = elt let compare = compare end) : Set.S with type elt := elt)
end

Jacques Garrigue

  parent reply	other threads:[~2013-06-23 23:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-23  7:16 David Allsopp
2013-06-23 15:14 ` Xavier Leroy
2013-06-23 23:15 ` Jacques Garrigue [this message]
2013-06-24  9:39   ` David Allsopp
2013-06-24 14:37     ` Kristopher Micinski
2013-06-24 14:41       ` Raphaël Proust
2013-06-24 19:13         ` Kristopher Micinski
2013-06-25  8:39       ` David Allsopp
     [not found] <563607038852382852@orange.fr>
2013-06-23  9:48 ` David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FE6DC106-80C6-4E4B-B8AE-2F97DC90A950@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).