mosml
mosml copied to clipboard
Examples for non-exhaustive pattern matches
Here's an example of a non-exhaustive pattern in Moscow ML:
- fun foo (x::xs) = xs;
! Toplevel input:
! fun foo (x::xs) = xs;
! ^^^^^^^^^^^^^^^^
! Warning: pattern matching is not exhaustive
Here's an example of the same non-exhaustive pattern in OCaml:
# let foo (x::xs) = xs;;
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
val foo : 'a list -> 'a list = <fun>
It'd be quite nice if Moscow ML, similarily to this, gave an example of an unmatched pattern.
I agree that this would be a nice feature to add, but I'm not sure how hard is to implement. Moscow ML has at least some of the needed machinery in place.