I wasn't able to repro the first issue with the latest internal version of F#, this could be a bug in the latest CTP.

As for the second issue, no it is not possible to use inheritance with Union Types. If you allow sub typing, many of the guarantees you get with union types go out the window. For example, if you had the derived class MyType1 you wouldn't know if:

Match x with

| NoAttribute

| Attribute(_)

Was an exhaustive match against MyType or an incomplete match against MyType1, similarly you can't infer what the type of x is.

Hope that helps.

By on 7/2/2008 9:08 AM ()

Thanks for the answer.

For the first issue, I'm looking foward to the next release of F# with this fixed.

About the second issue. That totally make sense. I'll just have to find a work around ;)

By on 7/2/2008 9:33 AM ()

Not an F# topic, but there were attemtps in functional languages to implement such subtyping for algebraic data types. Johan Nordlander's O'Haskell is an approach for such feature for non-recursive algebraic data types. Programming language researchers also have studied on subtyping recursive types from at least decades ago, but have not been implemented as a language feature in major functional languages. I am personally very intrested in this topic and we have recently submitted a paper on design of a langauge feature called <i>shared subtypes,<i> subtyping for recursive prametrized algebriac data types, to Haskell Symposium 2008.

By on 7/2/2008 2:16 PM ()

Programming language researchers also have studied on subtyping recursive types from at least decades ago, but have not been implemented as a language feature in major functional languages.

Actually OCaml's polymorphic variants already provide subtyping with recursive types, they have been widely used for years and OCaml remains one of the world's most popular general purpose functional programming languages.

Cheers,
Jon Harrop.

By on 7/7/2008 6:46 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