Hi,
you can always disable the warning, but I wouldn't recommend that - incomplete match is always a sign that something could go wrong and the warnings are really useful. (I wouldn't mind if it was an error actually). To disable it, you can use: #nowarn "25"

If the pattern matching fails, you'llget an exception, so you can also write an active pattern that always succeeds, but may throw an exception (that you define). This would look like this:

1
2
3
4
5
6
> let (|AOnly|) x =
    match x with | A(n) -> AOnly(n) | _ -> raise invalid_arg "Expected 'A' !!";;
val ( |AOnly| ) : Foo -> int

> let f (AOnly(x)) = 2*x;;
val f : Foo -> int

The question is whether you really want to throw an exception if someone calls the "f" function with a wrong argument. If you want, you can send larger example to show what you want to achieve.

T.

By on 10/8/2008 6:07 PM ()

I fixed the issue. What I was getting at though was it would be nice if the inference would take care of the fact that you cannot possible call f with anything but the A pattern of foo

By on 10/9/2008 7:31 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper