Skip to content

Instantly share code, notes, and snippets.

@Octachron
Last active July 11, 2025 14:00
Show Gist options
  • Save Octachron/6a229e959547d014b52ae4027ebd3ba9 to your computer and use it in GitHub Desktop.
Save Octachron/6a229e959547d014b52ae4027ebd3ba9 to your computer and use it in GitHub Desktop.
type any = [ `A | `B | `C ]
type _ t =
| A : [> `A ] t
| B: [> `B ] t
| C: [> `C ] t
let tag (type a) (x: a t) = match x with
| A -> 0
| B -> 1
| C -> 2
let l : any t list = [ A; B; C ]
let only_a_or_b (x: [`A | `B ] t) = match x with
| A -> 0
| B -> 1
| _ -> .
let test = only_a_or_b A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment