A list is a discriminated union -- what would it mean to subclass a discriminated union? How would your subclass get instantiated? Could you provide some sample (fake) code showing what you'd like to achieve? If you answer these, perhaps we can figure out what you're trying to accomplish. (Offhand, I can't think of anything you'd do with subclassing a DU in F# that can't be done in an other, clearer, way.)

By on 11/30/2009 11:47 AM ()

I'm not sure about the merits of inheriting an immutable linked list. If you noodle it for a little while you'll probably find that either (A) you really want to inherit a mutable list (see: System.Collections.Generic.List<'a>), or (B) you can accomplish what you want via aggregation (i.e. define a class that uses an immutable linked list internally). Of course, I'm not sure of your problem domain, so I'm just speculating.

By on 11/30/2009 8:15 AM ()

list<int> is a sealed type, so you can not inherit it.

Maybe it would be enough for you to extend list<'a> type like this:

1
2
3
 type Microsoft.FSharp.Collections.List<'a> with

  member this.MyProp = this.Length
By on 11/30/2009 6:03 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