Not quite sure what you're asking, but if you're not familiar with discriminated unions in F# (or algebraic data types in general), check them out.

[link:lorgonblog.spaces.live.com]

By on 3/8/2009 11:32 PM ()

Thanks, guys. I believe I got what I want. Discriminated unions is the problem. :)

By on 3/9/2009 9:37 AM ()

You can use active patterns as in :

1
2
3
4
5
6
7
8
9
10
11
 

type Foo(v:int) =
  member x.X = v

let (|FooA|FooB|) (x:Foo) = 
  match x.X with 
  | 0 -> FooA "aha" 
  | 1 -> FooB 1234 
  | _ -> invalid_arg "unexpected value" ;;

See the attached pdf at [link:blogs.msdn.com] for more information

By on 3/8/2009 11:15 PM ()

The value of a member of an object is not a part of that object's type. If you want an instance of A with the member Type set to 0, then give A a constructor which allows Type to be initialized, or if it's a public property, you can just initialize the property within the construction expression:

1
new A(Type = 0)

.

By on 3/8/2009 11:11 PM ()
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