Looks like an additional dispatch is necessary:

1
2
3
4
5
6
7
8
let f (v:obj) =
    match v with
    | :? T as t ->
        match t.Base with
        | :? A as a -> a.One
        | :? B as b -> b.Two
        | _ -> "Generic"
    | _ -> "Generic"
By on 4/30/2014 6:27 AM ()

Yes, I can't really see a more concise way to do it.

By on 5/1/2014 6:39 AM ()

Duplication of generic branch prone to errors once you need to change generic response. I thought of inner match already, but it doesn't look as concise as I used in F# :)

By on 5/4/2014 12:54 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