Say you had (imaginary syntax):On Fri, Jul 31, 2015 at 09:48:13AM -0400, Ashish Agarwal wrote:
> I have:
>
> type _ t =
> | Foo1 : 'a * int -> int t
> | Foo2 : 'a * string -> 'a t
>
> but I really want to merge these two cases. I want the return type to be
> based on the second arg when the second arg is int, and be based on the
> first arg otherwise. Any way to accomplish that?
type _ t =
| Foo : 'a * int -> int t
| Foo : 'a * string -> 'a t
let x1 = Foo (1, 1) : int t
let x2 = Foo (1, "x") : int t
match (x : int t) with
| Foo (a, b) -> ...
What is the type of (a, b) now? Is it (int, int) or (int, string)?
MfG
Goswin
--
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