Guest User

Untitled

a guest
Aug 18th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.52 KB | None | 0 0
  1. type _ op = Noop
  2. and _ t =
  3.     | Null : int t
  4.     | Op : 'e t * 'e op -> 'a t
  5.  
  6. (* when -principal is enabled, this function typechecks... *)
  7. let g : type a . a t -> unit =
  8.     fun t ->
  9.     let op_idx : int op * int =
  10.         match t with
  11.         | Null -> Noop, 1
  12.         | Op (Null, op) -> op, 2
  13.         | _ -> assert false in
  14.     let op, idx = op_idx in
  15.     ()
  16.  
  17. (* ...and this is not *)
  18. let f : type a . a t -> unit =
  19.     fun t ->
  20.     let (op, idx) : int op * int =
  21.         match t with
  22.         | Null -> Noop, 1
  23.         | Op (Null, op) -> op, 2
  24.         | _ -> assert false in
  25.     ()
Advertisement
Add Comment
Please, Sign In to add comment