is there (in theory) a relatively easy kind of annotation which could be added to type 'a t in a signature which would tell the compiler that 'a t and 'b are equal and compatible iff 'a and 'b are equal/compatible but still remain abstract?
Leo White wrote:
> Ben Millwood <bmillwood@janestreet.com> writes:
>
> > I think the issue would be substantially mitigated were it not for the
> > simple fact that [type 'a t] in a signature means "abstract type",
> > whereas [type 'a t] in a structure means "empty type". The fact that
> > there is no syntactic distinction, and indeed *no way to make one*
> > caused me a great deal of confusion some time ago when I had a problem
> > similar to David's.
The context of my original problem was the initially confusing assertion by the compiler that two "different" BatSet.t uses were the same. I guessed that what I was seeing was part of the "easy to shoot yourself in the foot" comment in its documentation!
> You can make an empty type (or at least a type for which there are no
> expressions) using:
>
> type 'a t = private T
The obvious "solution" with sets is to use the functor version therefore and have a module for each point (I believe that's 50% of the reason for doing it - the other being that you don't need to store the comparison function in the value itself), but is there (in theory) a relatively easy kind of annotation which could be added to type 'a t in a signature which would tell the compiler that 'a t and 'b are equal and compatible iff 'a and 'b are equal/compatible but still remain abstract?
David
--
Caml-list mailing list. Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs