-
Notifications
You must be signed in to change notification settings - Fork 789
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
[FS-1030] - Anonymous records #4499
Conversation
Updated to master, and now F# Interactive now works properly:
|
What is the story with type inference?
doesn't work (asks for type annotation) but lambdas are inferred fine. Is this by design? |
@majocha I think in the example you give, the type inference will only work with record types. I don't see why it would infer from anonymous type that happens to be defined in same scope. Lambdas are infered because they actually carry the type of the expression at their usage spot. the following type annotation should work: let y = {| V = "hi!" |}
let f (x: {|V:string|}) = x.V |
@majocha Yes, type annotations are necessary in cases where type information has not flowed to the point of use. This is a major limitation of the feature You can leave the types incomplete like this
but there is no row polymorphism. The addition of row-polymorphism for inlined-code could be considered separately |
OK, this feature is now ready. It would be great if someone could give this a full review, and if people could read the RFC very, very carefully. |
|
@Savelenko Thanks for that feedback - I will clarify the RFC and think about pattern matching. You are right that matching a subset of fields is already valid for records and makes sense for anonymous records too. It would not be hard to add. |
@Savelenko See fsharp/fslang-design#265, thanks |
The RFC mentions abbreviations a couple of times with regards to anonymous records - but I couldn't find any examples of how one would actually define such an abbreviation? Related to this - how will this function with regards to type inference e.g. imagine calling a function let foo bar =
bar.X + bar.Y where let foo (bar : {| X : int; Y : int |}) =
bar.X + bar.Y |
Would be so much fun to change this but I've not enough time :(
I agree with your feedback so far @fork!
Also pattern matching would be superb.
Anyways I'm still not sure how often I'm going to use anonymous records...
Am 15.03.2018 9:07 vorm. schrieb "Steffen Forkmann" <
notifications@github.com>:
… [image: image]
<https://user-images.githubusercontent.com/57396/37450935-38481280-2830-11e8-8b24-083f326ea556.png>
maybe we should print the field name in this case?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4499 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYPM8IG-6fdHd3YqZJV77PpeGMWJj28zks5teiE-gaJpZM4SnP8Z>
.
|
The CI failes with:
|
@isaacabraham some posts before @dsyme has already clarified this: You can leave the types incomplete like this let f (x: {|V: _|} ) = x.V" |
@gibranrosa cheers, I thought as much, but wasn't 100% sure what "abbreviations" meant though :-) |
@dotnet-bot Test Windows_NT Release_ci_part2 Build please |
@TIHan @KevinRansom can we get a review here? I really want to get this into 16.0 preview 2. |
wow!!! it's merged. It's in. Can't believe it. @ncave @alfonsogarciacaro did you see that? |
This should also be in nightlies for VS shortly. We'd really appreciate further validation work, as we do have some runway with upcoming VS 2019 previews to fix things prior to releasing a new language version. |
would be great to get a prerelease of FSharp.Compiler.Tools for us non-VS-usable folks to test as well. What's the process there? |
Yes it needs to go to fcs and then we test it in fable. Transpile to
dynamic language will be best test that you can get.
Am Di., 6. Nov. 2018, 19:29 hat Chet Husk <notifications@github.com>
geschrieben:
… would be great to get a prerelease of FSharp.Compiler.Tools for us
non-VS-usable folks to test as well. What's the process there?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4499 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNAWTxhwiOdvk5iXzRTW0rj6qo4U8ks5usdTwgaJpZM4SnP8Z>
.
|
To test it, we need FSharp.Compiler.Tools built from master. |
Wow, this is great, I was having an issue where I could really use this feature and now I come to find out it has been merged an hour ago. Way to go guys. :) |
@vasily-kirichenko Feel free to build FCT out of master. @forki you can build FCS out of master today - AFAIK this is what @Krzysztof-Cieslak does for some Ionide releases. We'll pull in other PRs related for an F# 4.6 and rev the versions of all assets so we can start shipping an F# 4.6 preview through the .NET CLI as well. |
This comment has been minimized.
This comment has been minimized.
As we've discussed before in a few places it is fairly difficult to roll out updates to all of the required tooling for all editor stacks instantly, even for master branch. FCT (fsharp/fsharp) and FCS (fsharp/FSharp.Compiler.Service) are built and released from master but I only tend to do that once the corresponding VS release corresponding to that master is near final. But I understand why it would be great to roll these out immediately. |
Has this been released in relative silence? I'm using VS 15.9.5 (no VF# nightlies) and am able to use anonymous records, but I can't find anything about this fantastic feature in any VS release notes. |
@cmeeren If you're using it then you have either a nightly build or a self-built VSIX installed. This was not released yet. |
Hm, strange. Does the information below indicate a version other than the one shipped with VS?
|
Check the extensions page (Tools > Extensions and Updates) to see the version there. |
Would you look at that, I did in fact have a nightly installed... 😅😳 I was certain I had uninstalled it long ago. Sorry for the trouble! |
I'm a bit sad about this. Without getting any hint from the F# team and after spending a lot of time to investigate this myself, I've finally realized this has shipped without including anonymous records in the AST exposed by |
@dsyme any idea what it would take to add the relevant case to this so that @alfonsogarciacaro Since it's still in preview things aren't quite baked yet. Though even if this were shipped I believe we could update FCS after the fact. |
@cartermp All the signs are the fsharp/FSharp.Compiler.Service repo and the corresponding nuget package are being abandoned. When someone wants to use FCS to test latest features they're encouraged to build it from this repository. However, there's no incentive to maintain the FCS API (beyond the symbols for editor support) when the developing in this repository, as the current situation has shown. The feeling is that anyone with a project relying on the Expression tree API from FCS should be prepared to become a maintainer of this repository to make sure new features get implemented in the Expression tree too. Something that my already stretched-too-thin time budget for OSS doesn't allow me to do. |
I acknowledge the current issue is annoying, but it's important to stress that the feature is still in preview and has only ever been advertised as such, so there's time to make sure we emit something Fable can consume before anything is considered completed. As for the FCS package/repo, we can put together a proposal to publish from this repository and make it a part of our release checklist. We can discuss the issue of maintaining the Expression Tree API as a part of that, if that's something that would be desirable. |
I’d rather not have release cycle of FCS coupled with VF#. Don has given NuGet release access to @baronfel so maybe we will see new releases more often. And TBF, we probably just need to write some automated sync process (for example using GitHub actions when they are out of closed preview). And as of omitting anon records in expression tree... it seems that was just small mistake, no need to make this as example of some deeper problem (https://twitter.com/dsyme/status/1091311874514321408?s=21) |
I'd echo what @Krzysztof-Cieslak has said. I'm on top of (and motivated to!) merge FCS with a more regular cadence and I look forward to automating/documenting that flow even moreso than has already been done in that repo. I'm working on making the periodic resyncs of FCS and fsharp/fsharp more painless for the community, but the first step from my perspective to to establish a routine of doing them quickly and painlessly, before automating it all away. |
Replaces #2671
This adds anonymous records to the F# compiler per RFC FS-1030.
Please discuss on the RFC or below - if the discussion gets long we will move to the RFC discussion thread.
The implementation is now complete (apart from copy-and-update) and I believe it to be stable and usable.
Implementation:
{| X = 1; Y = 2 |}
Kind B types{| X = 1; Y = 2 |}
Kind B typessprintf "%A"
on{| X = 1; Y = 2 |}
Kind B typesTesting:
For trial:
{| X = 1; Y = 2 |}
types for working with known common libraries accepting C# anonymous types (e.g. ASP.NET routing? ML.NET?)Here is the view of an anonymous value in the VS2017 debugger:
If anyone wants to give a hand with the testing that would be great. I think it's really important that someone else besides myself do serious testing on this feature. I'd love someone to try this out and give early feedback on usability and "fit and polish".