Version française
Home     About     Download     Resources     Contact us    
Browse thread
Private and type constraints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dario Teixeira <darioteixeira@y...>
Subject: Re: [Caml-list] Private and type constraints
Hi,

I just noted that there's already a ticket (#4580) related to this problem:
http://caml.inria.fr/mantis/view.php?id=4580

My doubts are a) whether the code below will be correct for 3.11 final;
and b) whether its semantics are equivalent to other uses of 'private',
namely that external pattern-matching on Foobar.t values is allowed,
but the construction of new values must be done through the constructor
functions.  Any thoughts?

Thanks in advance for your time!
Cheers,
Dario Teixeira
 
module Foobar:
sig
  type foo_t= [ `A ]
  type bar_t = [ `B ]
  type foobar_t = [ foo_t | bar_t ]
  type 'a t = private 'a constraint 'a = [< foobar_t ]
 
  val make_a: unit -> foo_t t
  val make_b: unit -> bar_t t
end =
struct
  type foo_t = [ `A ]
  type bar_t = [ `B ]
  type foobar_t = [ foo_t | bar_t ]
  type 'a t = 'a constraint 'a = [< foobar_t ]

  let make_a () = `A
  let make_b () = `B
end



      __________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html