This is a common problem that has annoyed me as well. The issue is that B sees foo and bar as abstract types, so cannot be sure they are different, so cannot be sure that a value of type foo gadt can't be constructed with Bar. If you add explicit constructors for both currently-empty types, then their inequality will be exposed and your pattern match should work. On 27 May 2015 at 16:04, Joris Giovannangeli wrote: > Hi, > > The following snippet is compiling without warning : > > module A = struct > > type foo > type bar > > type 'a gadt = > Foo : int -> foo gadt > | Bar : int -> bar gadt > > let f = function > | Foo i -> i > end > > But if I split the code into two modules : > > module A = struct > > type foo > type bar > > type 'a gadt = > Foo : int -> foo gadt > | Bar : int -> bar gadt > > end > > module B = struct > include A > > let f : foo gadt -> int = function > | Foo i -> i > end > > I get the following warning : > > Warning 8: this pattern-matching is not exhaustive. > Here is an example of a value that is not matched: > Bar _ > > How can i work around this issue ? As far as i can tell, it is not > possible for Bar to be matched by the function f. > > Best regards, > joris > > > -- > 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