Advertisement
Guest User

Untitled

a guest
Jun 28th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.85 KB | None | 0 0
  1. # type ('a, 'b) eq = Refl : ('a, 'a) eq;;
  2. type ('a, 'b) eq = Refl : ('a, 'a) eq
  3.  
  4. # module M : sig type 'a t val eq : ('a t, 'b t) eq val v : string t end = struct type 'a t = int let eq = Refl let v = 2 end;;
  5. module M : sig type 'a t val eq : ('a t, 'b t) eq val v : string t end
  6.  
  7. # let f (type a b) (Refl : (a M.t, b M.t) eq) (x: a M.t) : b M.t = x;;
  8. Line 1, characters 65-66:
  9. Error: This expression has type a M.t but an expression was expected of type
  10.          b M.t
  11.        Type a is not compatible with type b
  12.  
  13. # let f2 (type b) (Refl : (string M.t, b) eq) : b = M.v;;
  14. val f2 : (string M.t, 'b) eq -> 'b = <fun>
  15.  
  16. # let f3 (Refl : (string M.t, int M.t) eq) : int M.t = M.v;;
  17. Line 1, characters 53-56:
  18. Error: This expression has type string M.t
  19.        but an expression was expected of type int M.t
  20.        Type string is not compatible with type int
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement