-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFCs FS-1037, FS-1055] allow flexible inference (subsumption) at list/sequence/array yield points #4930
Conversation
@dsyme Could this also be allowed in more places? E.g. if an expression is known to be of type of an implemented interface member. |
Yes, but it needs care and can in some situations be very mild breaking change (basically some things can become slightly more generic, though that's almost always not a problem). That's one thing I'm assessing. Could you give an example please? You mean on method/property return? |
@dotnet-bot Test Ubuntu16.04 Release_default Build please |
@dsyme Yes, both methods and properties. /// Some external API
type IFoo =
interface
end
/// Some external API
type IBar =
abstract Method: unit -> IFoo
abstract Property: IFoo
type Foo() =
interface IFoo
type Bar() =
interface IBar with
member x.Method() = Foo() :> _
member x.Property = Foo() :> _ |
@auduchinok I've briefly looked at subsumption on the bodies of lambdas (which is my interpretation of what you're asking, or at least the natural way to implement it). This is w.r.t. subsumption based on the expected ("known") type of the lambda. It's potentially simple but there are some additional considerations. So I don't think it's good to do in a 4.5 timeframe. Perhaps 5.0. The change above is smaller and aligns sequence expressions with list/array expressions. The main issue is whether subsumption is for "the whole expression" or "the return points", e.g. consider
The question is really whether we allow each branch of the conditional to have independent subsumption flexibility. Likewise for the other branching constructs |
This is ready. We may add #2382 into this PR, as mentioned there, or do it shortly after |
This is now ready |
…on construction and list/sequence/array yield points (dotnet#4930) * allow flexible inference (subsumption) at list/sequence/array yield points * allow flexible inference (subsumption) at list/sequence/array yield points * suppress warnings for compat purposes * fix build * do not generalize IsCompatFlex variables to ensure code compat
It looks like I didn't push the commits for the union constructors (RFC FS-1037), they are now in #5030 |
RFC FS-1055: https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1055-subsumption-for-yield-in-sequence-expression.md
F# array and list computation expressions are great. However when you start to use
yield
you have to insert coercions, e.g.If the nominal type is known by type inference this should not be needed since the corresponding coercion is not needed for the simpler form.
This PR trial this language change.
RFC will follow tomorrow, I'm putting this in to run the whole test suite.