Note: this is a duplicate, but the original proposal was reduced down to only enable inheritance of such types, not implementation in F#.
I would like to ask you to reconsider fully implementing this feature.
Allow implementing the same interface at different generic instantiations in the same type
I propose we ...
Allow to implement the same interface multiple times with different generic instantiations.
E.g.
type I<'T> =
abstract member M : unit -> 'T
type T() =
interface I<int> with
member x.M = 1
interface I<bool> with
member x.M = true
The existing way of approaching this problem in F# is ...
The existing workaround is to create one extra level of inheritance per instantiation.
Pros and Cons
The advantages of making this adjustment to F# are ...
Feature parity with C#.
Reduce surprise for new developers.
Remove boilerplate inheritance chains caused by the workaround.
The disadvantages of making this adjustment to F# are ...
Quoting from UV:
[...] This is partly because of the way interface implementation methods are named in compiled IL (only the prefix "I" is added), and partly because the equivalent object expression form can inculde type unknowns, e.g.
{ interface I<> with ...
interface I<> with ...
and we don't want to support this kind of inference, and equally don't want a non-orthogonality between object expressions and class definitions. [...]
Extra information
Estimated cost (XS, S, M, L, XL, XXL): As this contains changes to code generation and type inference, this is probably M-L, but I am not familiar enough with the code base.
Related suggestions:
Original SO: http://stackoverflow.com/questions/1464109/implementing-the-same-interface-at-different-generic-instantiations
Original UV: https://fslang.uservoice.com/forums/245727-f-language/suggestions/5663504
Original PR: dotnet/fsharp#18
Affadavit (must be submitted)
Please tick this by placing a cross in the box:
- [ x ] 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 (It is a duplicate of the original suggestion)
- [ x ] 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. (As I understand it, the previous decision was more for technical reasons, e.g. the naming of interface methods)
Please tick all that apply:
Note: this is a duplicate, but the original proposal was reduced down to only enable inheritance of such types, not implementation in F#.
I would like to ask you to reconsider fully implementing this feature.
Allow implementing the same interface at different generic instantiations in the same type
I propose we ...
Allow to implement the same interface multiple times with different generic instantiations.
E.g.
The existing way of approaching this problem in F# is ...
The existing workaround is to create one extra level of inheritance per instantiation.
Pros and Cons
The advantages of making this adjustment to F# are ...
Feature parity with C#.
Reduce surprise for new developers.
Remove boilerplate inheritance chains caused by the workaround.
The disadvantages of making this adjustment to F# are ...
Quoting from UV:
Extra information
Estimated cost (XS, S, M, L, XL, XXL): As this contains changes to code generation and type inference, this is probably M-L, but I am not familiar enough with the code base.
Related suggestions:
Original SO: http://stackoverflow.com/questions/1464109/implementing-the-same-interface-at-different-generic-instantiations
Original UV: https://fslang.uservoice.com/forums/245727-f-language/suggestions/5663504
Original PR: dotnet/fsharp#18
Affadavit (must be submitted)
Please tick this by placing a cross in the box:
Please tick all that apply: