ML is a typed language. Your explicit type annotation determines that the second argument of the function has type int
(which actually is already determined implicitly by its comparison to 0, so the annotation is redundant). So obviously, there cannot be anything other than an integer to match, and the type system knows it.
(Edit: Stylistic note: better throw an exception (e.g. the predefined Domain
) in case that n < 0
, rather than silently returning a random default result.)