caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <lpw25@cam.ac.uk>
To: "Milan Stanojević" <milanst@gmail.com>
Cc: Alain Frisch <alain.frisch@lexifi.com>,
	 Jeremie Dimino <jdimino@janestreet.com>,
	 Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] open extensible types representation
Date: Thu, 15 May 2014 00:33:30 +0100	[thread overview]
Message-ID: <8638gcj5px.fsf@cam.ac.uk> (raw)
In-Reply-To: <CAKR7PS9T+rUPv3MG-KKn-um7zdC3nDVanUzD+fC_Yi0zyc26SA@mail.gmail.com> ("Milan \=\?utf-8\?Q\?Stanojevi\=C4\=87\=22's\?\= message of "Wed, 14 May 2014 16:56:53 -0400")

> The rebinding of constructors is interesting. What are uses case apart
> from reducing verbosity in some cases?

Naming a constructor created by a functor.

For example, the following excerpts from my own toy example
(testsuite/tests/typing-extensions/msg.ml in the ocaml sources):

    module Msg : sig

      type 'a tag

      (* ... *)

      module Define (D : Desc) : sig
        type 'a tag += C : D.t tag
      end

    end = struct

      type 'a tag = ..

      (* ... *)

    end

    (* ... *)

    module StrM = Msg.Define(struct
      type t = string
      (* ... *)
    end);;

    type 'a Msg.tag += String = StrM.C;;

Note that the `Msg.tag` type has been made abstract, so the `Define`
functor is the only method of creating new constructors.

The rebinding gives the `String` constructor a meaningful name, and
allows you to expose it in your interface rather than expose all of
`StrM`.

Regards,

Leo

  reply	other threads:[~2014-05-14 23:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 15:53 Milan Stanojević
2014-05-13 16:07 ` Jeremie Dimino
2014-05-13 16:08   ` Jeremie Dimino
2014-05-13 16:39     ` Milan Stanojević
2014-05-13 16:57       ` Jeremie Dimino
2014-05-14 18:11         ` Milan Stanojević
2014-05-14 18:41           ` Alain Frisch
     [not found]             ` <5373B924.9020206@lexifi.com>
2014-05-14 20:56               ` Milan Stanojević
2014-05-14 23:33                 ` Leo White [this message]
2014-05-13 16:37 ` Frédéric Bour
2014-05-13 17:51   ` Frédéric Bour

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=8638gcj5px.fsf@cam.ac.uk \
    --to=lpw25@cam.ac.uk \
    --cc=alain.frisch@lexifi.com \
    --cc=caml-list@inria.fr \
    --cc=jdimino@janestreet.com \
    --cc=milanst@gmail.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).