caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pattern match fall-through for GADTs
@ 2013-12-23 19:25 Misha Aizatulin
  0 siblings, 0 replies; only message in thread
From: Misha Aizatulin @ 2013-12-23 19:25 UTC (permalink / raw)
  To: caml-list

hi all,

  I decided to give GADTs a go and realized that I don't know how to
make pattern matches fall through in a familiar fashion. The code [1]
below gets accepted but [2] does not. Is there anything I can do to
avoid spelling out the same case several times?

Best,
  Misha

[1]
type 'a t =
| I1 : int t
| I2 : int t
| B1 : bool t
| B2 : bool t

let f (type a) (t : a t) =
  match t with
  | I1 -> 0
  | I2 -> 0
  | B1 -> 1
  | B2 -> 1

[2]
let f (type a) (t : a t) =
  match t with
  | I1
  | I2 -> 0
  | B1
  | B2 -> 1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-23 19:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-23 19:25 [Caml-list] Pattern match fall-through for GADTs Misha Aizatulin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).