Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Matching exhausitvity with GADT and modules
@ 2015-05-27 15:04 Joris Giovannangeli
  2015-05-27 15:14 ` Ben Millwood
  0 siblings, 1 reply; 6+ messages in thread
From: Joris Giovannangeli @ 2015-05-27 15:04 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-27 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 15:04 [Caml-list] Matching exhausitvity with GADT and modules Joris Giovannangeli
2015-05-27 15:14 ` Ben Millwood
2015-05-27 15:22   ` Joris Giovannangeli
2015-05-27 15:36     ` Yannis Juglaret
2015-05-27 20:22       ` Alain Frisch
2015-05-27 15:43   ` Arseniy Alekseyev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox