From: Alain Frisch <alain@frisch.fr>
To: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
Cc: David Allsopp <dra-news@metastack.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: module typing issue
Date: Mon, 28 Mar 2011 14:23:50 +0200 [thread overview]
Message-ID: <4D907DD6.2030507@frisch.fr> (raw)
In-Reply-To: <20110328115831.GW20598@localhost>
On 03/28/2011 01:58 PM, Guillaume Yziquel wrote:
> Yes an no. From a type inference perspective, that's right. However, you
> can already do such pattern matching on private row types for variant
> types.
>
> module X : sig
> type t = private [< `A ]
> val x : t
> end = struct
> type t = [ `A ]
> let x = `A
> end
>
> match X.x with `A -> ()
>
> and the X.x is correctly unified with `A. So the type inference issue is
> solved in this case.
Private row types are not the same as private type abbreviations. The
syntax might be a source of confusion here, but the keyword "private"
really means three different things:
- Private type declarations: constructors/labels are available for
deconstructing values (pattern matching, dot notation), not for building
values.
- Private type abbreviations (where the abbreviated type is not an
object type or a polymorphic variant type): the behavior is very much
the same as an abstract type, except that the abbreviation is a subtype
of the abbreviated type (and the compiler can use the concrete type to
choose a runtime representation of -- e.g. for records of floats -- and
to trigger optimizations).
- Private row types: you can think of the 'private' annotation as a way
to name (as an abstract type) the implicit row type variable of the
abbreviated type. There is no hiding as for type abbreviation and no
access control as for private type declarations.
The syntax for private type abbreviation and private row types is the
same; they are distinguished only in the type-checker. As far as I know,
there is no way to create a private type abbreviation on a object or
variant type.
Alain
next prev parent reply other threads:[~2011-03-28 12:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-25 8:34 [Caml-list] " Joel Reymont
2011-03-25 8:44 ` [Caml-list] " Joel Reymont
2011-03-25 14:17 ` Joel Reymont
2011-03-25 15:46 ` Andreas Rossberg
2011-03-25 15:57 ` Joel Reymont
2011-03-25 16:04 ` Andreas Rossberg
2011-03-25 16:42 ` Guillaume Yziquel
2011-03-25 16:59 ` Andreas Rossberg
2011-03-25 19:01 ` Guillaume Yziquel
2011-03-25 19:13 ` Andreas Rossberg
2011-03-28 7:53 ` Alain Frisch
2011-03-28 10:33 ` Guillaume Yziquel
2011-03-28 11:29 ` David Allsopp
2011-03-28 11:58 ` Guillaume Yziquel
2011-03-28 12:11 ` David Allsopp
2011-03-28 12:29 ` Guillaume Yziquel
2011-03-28 12:23 ` Alain Frisch [this message]
2011-03-28 12:39 ` Guillaume Yziquel
2011-03-28 11:32 ` David Allsopp
2011-03-28 12:02 ` Guillaume Yziquel
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=4D907DD6.2030507@frisch.fr \
--to=alain@frisch.fr \
--cc=caml-list@inria.fr \
--cc=dra-news@metastack.com \
--cc=guillaume.yziquel@citycable.ch \
/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