You can use :? operator to exactly test classes

and :> operator to test is given class parent of your class.

1
2
3
4
5
6
7
open Calc

let rec eval (expr:Expr) =
    match expr with
    | :? Sum -> (eval expr.x) + (eval expr.y)

    //...
By on 11/8/2007 1:07 AM ()

Thanks for the answer. I really have overlooked the :? and :> operators.

By on 11/9/2007 6:42 AM ()

Active patterns may be an option, there's a good description of how they work here:
[link:www.infoq.com]

Cheers,
Rob

By on 11/8/2007 4:26 AM ()

Thanks for the tip on active patterns. They seem very interesting. The downside is that one have to redefine the data structures. Is there any workaround for that? I mean, any way to do not have to redefine the data structures?

By on 11/9/2007 6:45 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