code_junkie

Understanding the type error: “expected signature Int*Int->Int but got Int*Int->Int”

Nov 12th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. expected signature Int*Int->Int but got Int*Int->Int
  2.  
  3. let f x y = x + y;;
  4.  
  5. val f : int -> int -> int
  6.  
  7. f(1, 2)
  8.  
  9. fun f g = g (1, 2);
  10.  
  11. f (42, fn x => x * 2)
  12.  
  13. # let f x = x + 1;;
  14. val f : int -> int = <fun>
  15. # type int = Foo of string;;
  16. type int = Foo of string
  17. # f (Foo "hello");;
  18. This expression has type int but is here used with type int
  19.  
  20. # let f g x y = g(x,y) + x + y;;
  21. val f : (int * int -> int) -> int -> int -> int = <fun>
  22. # type int = Foo of int;;
  23. type int = Foo of int
  24. # let h (Foo a, Foo b) = (Foo a);;
  25. val h : int * int -> int = <fun>
  26. # f h;;
  27. This expression has type int * int -> int but is here used with type
  28. int * int -> int
Add Comment
Please, Sign In to add comment