caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Stéphane Lescuyer" <lescuyer@lri.fr>
To: "Hezekiah M. Carty" <hcarty@atmos.umd.edu>
Cc: "Romain Bardou" <Romain.Bardou@lri.fr>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Attach an invariant to a type
Date: Thu, 31 Jan 2008 20:29:01 +0100	[thread overview]
Message-ID: <e9e94ac90801311129k1b1d7318q213c3ef595be433e@mail.gmail.com> (raw)
In-Reply-To: <3a360f590801311113o4db1d660s206e7af4bcb3226@mail.gmail.com>

On Jan 31, 2008 8:13 PM, Hezekiah M. Carty <hcarty@atmos.umd.edu> wrote:
>
> This code does not work for me.  I get a "This fixed type is not an
> object or variant" error on the "type t = private int" line.  From the
> manual it looks like you would have to use something like this:
>
> type t = private Index of int
>
> to take advantage of private types.  Am I missing something?
>

No you're not :) as far as I know, a private type can only be a record
or a variant.
It prevents one from constructing values of this type, but still
allows pattern-matching
on these values.

I guess that making types like "int" private would require the system
(among other things) to decide whether you're using a given integer as
a Subindex.t or not. At first glance, it seems it is a harder problem
than just forbidding the construction of any value of a given type.
Just my 0.02€ :-)

Stéphane L.


  reply	other threads:[~2008-01-31 19:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 13:28 Dawid Toton
2008-01-31 13:50 ` [Caml-list] " Romain Bardou
2008-01-31 17:58   ` David Teller
2008-01-31 18:13     ` Romain Bardou
2008-01-31 19:13       ` Hezekiah M. Carty
2008-01-31 19:29         ` Stéphane Lescuyer [this message]
2008-01-31 19:51           ` Dawid Toton
2008-01-31 20:26             ` Edgar Friendly
2008-02-01 10:00               ` Keiko Nakata
2008-01-31 20:13           ` Romain Bardou
2008-02-10 18:00           ` Stéphane Glondu

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=e9e94ac90801311129k1b1d7318q213c3ef595be433e@mail.gmail.com \
    --to=lescuyer@lri.fr \
    --cc=Romain.Bardou@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=hcarty@atmos.umd.edu \
    /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).