mosml icon indicating copy to clipboard operation
mosml copied to clipboard

Examples for non-exhaustive pattern matches

Open Eckankar opened this issue 14 years ago • 1 comments

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.

Eckankar avatar Nov 03 '11 11:11 Eckankar

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.

kfl avatar Nov 04 '11 12:11 kfl