* type constraints involving variant types
@ 2007-03-16 10:43 Christian Sternagel
2007-03-16 13:07 ` Zheng Li
0 siblings, 1 reply; 3+ messages in thread
From: Christian Sternagel @ 2007-03-16 10:43 UTC (permalink / raw)
To: caml-list
Is it possible to give type constraints involving variant types?
If there is e.g.
module type A = sig
type t = A of 'a | B of 'b
end
module type B = sig
module A : A
end
Can I then do something like
module type C = sig
module B : B
module A : A
with type t = B.A.t = A of 'a | B of 'b
end
The above yields a syntax error, but there should be a way of doing
that or not?
cheers
christian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: type constraints involving variant types
2007-03-16 10:43 type constraints involving variant types Christian Sternagel
@ 2007-03-16 13:07 ` Zheng Li
2007-03-16 15:44 ` [Caml-list] " Christian Sternagel
0 siblings, 1 reply; 3+ messages in thread
From: Zheng Li @ 2007-03-16 13:07 UTC (permalink / raw)
To: caml-list
Not sure if this is what you want:
# module type C = sig
module A: A
module B: B with module A = A
end;;
module type C =
sig
module A : A
module B : sig module A : sig type t = A.t = A of int | B of string end end
end
Christian Sternagel <christian.sternagel@uibk.ac.at> writes:
> module type A = sig
> type t = A of 'a | B of 'b
> end
>
> module type B = sig
> module A : A
> end
>
> Can I then do something like
>
> module type C = sig
> module B : B
> module A : A
> with type t = B.A.t = A of 'a | B of 'b
> end
>
--
Zheng Li
http://www.pps.jussieu.fr/~li
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Re: type constraints involving variant types
2007-03-16 13:07 ` Zheng Li
@ 2007-03-16 15:44 ` Christian Sternagel
0 siblings, 0 replies; 3+ messages in thread
From: Christian Sternagel @ 2007-03-16 15:44 UTC (permalink / raw)
To: Zheng Li, caml-list
On Fri, Mar 16, 2007 at 02:07:50PM +0100, Zheng Li wrote:
>
> Not sure if this is what you want:
>
> # module type C = sig
> module A: A
> module B: B with module A = A
> end;;
> module type C =
> sig
> module A : A
> module B : sig module A : sig type t = A.t = A of int | B of string end end
> end
Thanks a lot! That finally worked... after days of type contraints, the obvious solutions get somehow lost.
cheers
christian
>
> Christian Sternagel <christian.sternagel@uibk.ac.at> writes:
> > module type A = sig
> > type t = A of 'a | B of 'b
> > end
> >
> > module type B = sig
> > module A : A
> > end
> >
> > Can I then do something like
> >
> > module type C = sig
> > module B : B
> > module A : A
> > with type t = B.A.t = A of 'a | B of 'b
> > end
> >
>
> --
> Zheng Li
> http://www.pps.jussieu.fr/~li
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-16 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-16 10:43 type constraints involving variant types Christian Sternagel
2007-03-16 13:07 ` Zheng Li
2007-03-16 15:44 ` [Caml-list] " Christian Sternagel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox