Allow intrinsic type extensions for provided types #509

Open
7sharp9 opened this Issue Nov 5, 2016 · 7 comments

Comments

Projects
None yet
4 participants
@7sharp9
Member

7sharp9 commented Nov 5, 2016

Allow intrinsic type extensions for provided types

I propose we allow intrinsic type extensions for provided types

Currently a compiler error is reported if this is attempted:

Error FS0192: internal error: FindTypeDefBuilder: <Method> not found (FS0192) (<Application>)

Usage Example

Given a generative type provider that simply creates a generated type with a method named MyMethod and a property name MyProperty, and then intrinsically extends it adding a Foo property.

type t = BasicProvider.Generative.MyType with
  member x.Foo = 42

or long code form:

type t = BasicProvider.Generative.MyType

type t with 
    member x.Foo = 42

The resultant type would look like this:

type t =
  class
    new : unit -> t
    member Foo : int
    member MyMethod : unit -> string
    member MyProperty : string

Pros and Cons

The advantages of making this adjustment to F# are provided types can have extension added to them that much like partial classes in C# are used with generated code. This is extremely advantages to code generation mechanism involved in GUI libraries

The disadvantages of making this adjustment to F# are added testing and implementation. The language spec would have to be amended to un-depreciate the use of with to override and add member to only provided types.

Extra information

Estimated cost (M):
This has already been partial implemented in Microsoft/visualfsharp#882

Affadavit

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I would be willing to help implement and/or test this
  • I or my company would be willing to help crowdfund F# Software Foundation members to work on this
@cloudRoutine

This comment has been minimized.

Show comment
Hide comment
@cloudRoutine

cloudRoutine Mar 24, 2017

Collaborator

@dsyme wasn't this approved?

Collaborator

cloudRoutine commented Mar 24, 2017

@dsyme wasn't this approved?

@dsyme

This comment has been minimized.

Show comment
Hide comment
@dsyme

dsyme Mar 24, 2017

Collaborator

@cloudRoutine Yes, it's just really hard to implement :)

Collaborator

dsyme commented Mar 24, 2017

@cloudRoutine Yes, it's just really hard to implement :)

@7sharp9

This comment has been minimized.

Show comment
Hide comment
@7sharp9

7sharp9 Mar 24, 2017

Member

@dsyme Was the problem simply with the mechanism being used in fsi?

Member

7sharp9 commented Mar 24, 2017

@dsyme Was the problem simply with the mechanism being used in fsi?

@7sharp9

This comment has been minimized.

Show comment
Hide comment
@7sharp9

7sharp9 Mar 24, 2017

Member

The generated code from the compiler did indeed look correct for generative types, once thing that did need to be addressed was adjusting the language spec to un-depriciate the warning of using obsolete syntax in the definition of the intrinsically extended types.

Member

7sharp9 commented Mar 24, 2017

The generated code from the compiler did indeed look correct for generative types, once thing that did need to be addressed was adjusting the language spec to un-depriciate the warning of using obsolete syntax in the definition of the intrinsically extended types.

@7sharp9

This comment has been minimized.

Show comment
Hide comment
@7sharp9

7sharp9 Sep 17, 2017

Member

@dsyme Is there a way we can potentially progress this? From my experience the only issue was no one understood the relocation of types in fsi, and also removing the warnings generated due to the the use of with to override and add member to only provided types.

Member

7sharp9 commented Sep 17, 2017

@dsyme Is there a way we can potentially progress this? From my experience the only issue was no one understood the relocation of types in fsi, and also removing the warnings generated due to the the use of with to override and add member to only provided types.

@realvictorprm

This comment has been minimized.

Show comment
Hide comment
@realvictorprm

realvictorprm Sep 17, 2017

Member

If no one has time to implement it further but can collect the necessary information I'm willing to do it.

Member

realvictorprm commented Sep 17, 2017

If no one has time to implement it further but can collect the necessary information I'm willing to do it.

@dsyme dsyme added the needs rfc label Dec 1, 2017

@7sharp9

This comment has been minimized.

Show comment
Hide comment
@7sharp9

7sharp9 Jul 5, 2018

Member

I'll start writing the RFC as I get time...

Member

7sharp9 commented Jul 5, 2018

I'll start writing the RFC as I get time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment