Recently, I was surprised to realize that the following is accepted by OCaml :
─( 16:19:10 )─< command 0 >──────────────────────────────────────{ counter: 0 }─
utop # let example (type a) x="see?";;
val example : 'a -> string = <fun>
─( 16:19:11 )─< command 1 >──────────────────────────────────────{ counter: 0 }─
utop # example 5;;
- : string = "see?"
─( 16:19:35 )─< command 2 >──────────────────────────────────────{ counter: 0 }─
utop # example "6";;
- : string = "see?"
I expected the first command to be a syntax error, and thought the type
keyword’s only use is to define new type. Seems that I was wrong … Where is this documented and explained in the manual ?