caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Private types and subtyping
@ 2015-05-11 16:31 Stephen Dolan
  2015-05-11 17:10 ` Jeremy Yallop
  2015-05-13 20:09 ` Leo White
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Dolan @ 2015-05-11 16:31 UTC (permalink / raw)
  To: Ocaml Mailing List

My intuition is that exporting a private type from a module with "type
t = private foo" makes "t" a new subtype of "foo". So, any means of
eliminating "foo" can eliminate "t", but constructing my own "foo"
does not necessarily mean I've made a "t".

This intuition also says the following should be OK:

    module Sub : sig
      type t = private [`A | `B]
    end = struct
      type t = [`A]
    end

The compiler (4.02.1) rejects this. Is this just a missing feature, or
is there some deep reason I'm missing why the above is not OK?

Stephen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Private types and subtyping
  2015-05-11 16:31 [Caml-list] Private types and subtyping Stephen Dolan
@ 2015-05-11 17:10 ` Jeremy Yallop
  2015-05-13 20:09 ` Leo White
  1 sibling, 0 replies; 3+ messages in thread
From: Jeremy Yallop @ 2015-05-11 17:10 UTC (permalink / raw)
  To: Stephen Dolan; +Cc: Ocaml Mailing List

On 11 May 2015 at 17:31, Stephen Dolan <stephen.dolan@cl.cam.ac.uk> wrote:
> My intuition is that exporting a private type from a module with "type
> t = private foo" makes "t" a new subtype of "foo". So, any means of
> eliminating "foo" can eliminate "t", but constructing my own "foo"
> does not necessarily mean I've made a "t".
>
> This intuition also says the following should be OK:
>
>     module Sub : sig
>       type t = private [`A | `B]
>     end = struct
>       type t = [`A]
>     end
>
> The compiler (4.02.1) rejects this. Is this just a missing feature, or
> is there some deep reason I'm missing why the above is not OK?

This isn't quite an answer to your question, but private rows might do
what you need:

   module Sub : sig
     type t = private [<`A | `B]
   end = struct
     type t = [`A]
   end

Jeremy.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Private types and subtyping
  2015-05-11 16:31 [Caml-list] Private types and subtyping Stephen Dolan
  2015-05-11 17:10 ` Jeremy Yallop
@ 2015-05-13 20:09 ` Leo White
  1 sibling, 0 replies; 3+ messages in thread
From: Leo White @ 2015-05-13 20:09 UTC (permalink / raw)
  To: Stephen Dolan; +Cc: Ocaml Mailing List

> The compiler (4.02.1) rejects this. Is this just a missing feature, or
> is there some deep reason I'm missing why the above is not OK?

I believe that this is just a missing feature rather than something which
would be unsound or impracticable to implement.

Regards,

Leo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-13 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-11 16:31 [Caml-list] Private types and subtyping Stephen Dolan
2015-05-11 17:10 ` Jeremy Yallop
2015-05-13 20:09 ` Leo White

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).