Advertisement
Guest User

Untitled

a guest
Dec 10th, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.45 KB | None | 0 0
  1. type (_, _) eq = Eq : ('a, 'a) eq;;
  2.  
  3. module M1 : sig
  4.   type t
  5.   val is_int : t -> (t, int) eq
  6. end = struct
  7.   type t = int
  8.   let is_int (x: t) = (Eq: (t, int) eq)
  9. end
  10.  
  11. let foo' (type t) (x: t) (e: (t, int) eq) =
  12.   let Eq = e in x + 1
  13.  
  14. let foo (x: M1.t) =
  15.   foo' x (M1.is_int x)
  16.  
  17. (*let bar' (x: M1.t) (e: (M1.t, int) eq) =
  18.   let Eq = e in x + 1*)
  19. (*Error: This expression has type M1.t but an expression was expected of type
  20.          int
  21. *)
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement