From: "Eric C. Cooper" <ecc@cmu.edu>
To: caml-list@inria.fr
Cc: ijtrotts@ucdavis.edu
Subject: Re: [Caml-list] References to polymorphic variants
Date: Wed, 25 Feb 2004 20:49:37 -0500 [thread overview]
Message-ID: <20040226014937.GB4099@localhost> (raw)
In-Reply-To: <20040225230719.GA1148@manzanita>
On Wed, Feb 25, 2004 at 03:07:19PM -0800, Issac Trotts wrote:
> He's talking about compiling it, which is slightly different:
>
> $ cat foo.ml
> let (x : ([> ] option) ref ) = ref None ;;
>
> $ /usr/bin/ocamlc -c foo.ml
> File "foo.ml", line 1, characters 31-39:
> The type of this expression, _[> ] option ref,
> contains type variables that cannot be generalized
>
> The set of values that x can have is still unspecified, so there is
> implicitly a type variable whose value needs to be nailed down before
> the example can compile. Here's a way to work around it:
>
> type t = [ `bleh | `woof ];;
> let x = ref (None : t option);;
Or, he can just use x in the scope of that module, if that's
sufficient for his application.
$ cat foo.ml
let (x : [> ] option ref) = ref None
let () =
x := Some `Apple;
x := Some (`Pair (17, "foo"));
x := Some `Cheese
$ ocamlc -i -c foo.ml
val x : _[> `Apple | `Cheese | `Pair of int * string ] option ref
--
Eric C. Cooper e c c @ c m u . e d u
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-02-26 1:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-25 16:05 nickgrey
2004-02-25 22:41 ` Eric C. Cooper
2004-02-25 23:07 ` Issac Trotts
2004-02-26 1:49 ` Eric C. Cooper [this message]
2004-02-26 1:53 ` Eric C. Cooper
2004-02-26 4:39 ` Jacques Garrigue
2004-02-25 22:56 ` [Caml-list] Re: Caml-list " Remi Vanicat
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=20040226014937.GB4099@localhost \
--to=ecc@cmu.edu \
--cc=caml-list@inria.fr \
--cc=ijtrotts@ucdavis.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