I don't what exactly what you are trying to do.

But as you noted the code does not compile due to type mismatch.

But I'd guess that if you want to match against

1
2
3
4
type Model  = 
| Model1 of int
| Model2 of double
| Model3 

Then you should have

1
2
3
4
type ModelResult =
  | ModelResult1 of (int * int -> int)
  | ModelResult2 of (int * double -> double)
  | ModelResult3 of (int -> bool)

as return from the match statement

so your code becomes :

1
2
3
4
5
let GetFunc(m:Model) = 
    match m with
    | Model1 i -> ModelResult1(fun (x,y) -> i)
    | Model2 d -> ModelResult2(fun (x,y) -> d)
    | Model3 -> ModelResult3(fun x -> true)

You'll have to pattern match result and call and then call the function.

By on 11/8/2010 11:30 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