-
-
Save mcclure/ca35bba1a961ee5bc2e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* PROGRAM #1: "GOOD.ML" *) | |
let ignore = 1;; | |
let rec tableBlank k = | |
makeLet ignore 1 | |
and makeLet (a:int) (b:int) = | |
a + b;; | |
let () = print_endline @@ string_of_int @@ makeLet 1 2;; | |
(* WHAT I GET IF I RUN PROGRAM #1: | |
3 | |
*) | |
(* PROGRAM #2: "BAD.ML" *) | |
let ignore = 3.0;; | |
let rec tableBlank k = | |
makeLet ignore 1 (* THIS LINE IS A TYPO *) | |
and makeLet (a:int) (b:int) = (* THIS LINE IS CORRECT *) | |
a + b;; | |
let () = print_endline @@ string_of_int @@ makeLet 1 2;; | |
(* WHAT I GET IF I RUN PROGRAM #2: | |
File "bad.ml", line 6, characters 12-19: | |
Error: This pattern matches values of type int | |
but a pattern was expected which matches values of type float | |
*) | |
(* WHY I'M BOTHERED: If I explicitly decorated makeLet with a:int type, | |
shouldn't that take precedence over the inferred type from tableBlank? *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment