caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: Caml list <caml-list@inria.fr>
Subject: [Caml-list] Type variables (was: Odd Type Checking Problem)
Date: Thu, 7 Feb 2002 12:21:43 +0100 (MET)	[thread overview]
Message-ID: <Pine.GSO.4.33.0202071205590.24659-100000@clipper.ens.fr> (raw)
In-Reply-To: <Pine.GSO.4.33.0202062353100.22609-100000@clipper.ens.fr>

Hello,

On Wed, 6 Feb 2002, I wrote:

> I guess this is a problem of understanding type variable scoping rules.


Actually, I feel myself somewhat confused with implicit introduction and
scoping of type variables.

These one are refused:

let f (x : 'a) = let module M = struct exception X of 'a end in ();;
let f (x : 'a) = let module M = struct type t = 'a end in ();;

This is accepted:

let f (x : 'a) =
  let module M =
      struct
	type t constraint t = 'a;;
	exception X of t;;
      end in ();;

but is quite useless, since both:

let f (x : 'a) =
  let module M =
      struct
	type t constraint t = 'a;;
	exception X of t;;
	raise (X x);;
      end in ();;

and

let f (x : 'a) =
  let module M =
      struct
        type t constraint t = 'a;;
        exception X of t;;
      end in raise (M.X x);;


are rejected by the type checker.

(in "constraint ...", no new variable is introduced)


Another example:

let f (x : 'a) =
  let module M =
      struct
        type u = { a : 'a }
      end in ();;

=> rejected (Unbound type parameter 'a)

(and accepted by
"Objective Caml version 3.04+1 with explicit polymorphism (2002-01-07)",
but with a different meaning that one could expect)


Is there a way to use a type variable such as the 'a above to define
types in a local structure ?


-- Alain

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2002-02-07 11:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-06 19:37 [Caml-list] Odd Type Checking Problem Jonathan D Eddy
2002-02-06 22:59 ` Alain Frisch
2002-02-07  9:45   ` Tom Hirschowitz
2002-02-07 10:04     ` Tom Hirschowitz
2002-02-07 11:21   ` Alain Frisch [this message]
2002-02-07 12:25     ` [Caml-list] Type variables (was: Odd Type Checking Problem) Markus Mottl
2002-02-08  1:33       ` Jacques Garrigue
2002-02-08  9:24         ` Markus Mottl
2002-02-07  3:15 ` [Caml-list] Odd Type Checking Problem stalkern2
2002-02-06 21:19   ` 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=Pine.GSO.4.33.0202071205590.24659-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=caml-list@inria.fr \
    /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).