Skip to content
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

Support provided union and record types #154

Open
baronfel opened this issue Oct 20, 2016 · 7 comments
Open

Support provided union and record types #154

baronfel opened this issue Oct 20, 2016 · 7 comments

Comments

@baronfel
Copy link
Contributor

baronfel commented Oct 20, 2016

Submitted by Gustavo Guerra on 3/21/2014 12:00:00 AM
111 votes on UserVoice prior to migration

Title says it all

Original UserVoice Submission
Archived Uservoice Comments

@dsyme
Copy link
Collaborator

dsyme commented Oct 29, 2016

** by fslang-admin on 2/4/2016 12:00:00 AM **

Marking as “approved in principle” (it will show as “planned”). However, in reality it is both relatively low priority and relatively hard to implement, so I don’t expect this to happen any time soon. For example, we would have to reverse-map the metadata associated with F#-specific types. This is already done in F# reflection FSharpType.IsRecord and so on.

@7sharp9
Copy link
Member

7sharp9 commented Jul 13, 2018

I propose we split this in two, add provided records, add provided unions.

@dsyme I know you said provided active patterns could be more generally usable than unions, maybe this could be fleshed out?

@dsyme
Copy link
Collaborator

dsyme commented Oct 9, 2018

I propose we split this in two, add provided records, add provided unions.

For RFCs yes, we can do two separate ones

@dsyme I know you said provided active patterns could be more generally usable than unions, maybe this could be fleshed out?

Here's the quick summary: APs are defined as module-let functions. Provided module-let functions and values are not supported. Hence the first step would probably be to allow those, then APs should drop out as part of that.

@7sharp9
Copy link
Member

7sharp9 commented Oct 9, 2018

@dsyme I actually have ProvidedUnions and ProvidedRecords in Falanx :-)
obviously I have different parameters and constraints

@dsyme
Copy link
Collaborator

dsyme commented May 7, 2019

Added a relevant comment to one of the above discussions:

  1. Why isn't it possible to generate F# specific types (aren't they just nested classes with custom attributes/metadata after all) ?

The main thing is that it's just a lot of work. The way TPs are architected (providing .NET System.Type/MethodInfo etc. and the compiler converts them to F# TAST nodes) effectively means we have to fully invert the compilation process from .NET IL types --> F# TAST types. This is implemented in tast.fs and infos.fs in the F# compiler for methods, types, properties, events but there is no corresponding inversion for F#-defined union/record types.

The inversion would be similar to that implemented in FSharp.Reflection.FSharpType/FSharpValue based on the attributes etc. But it's painful to implement and fully test accurately.

  1. Is there a general interest in making this possible (or is it just me wanting this) ?

Yes, people are interested in this

@7sharp9
Copy link
Member

7sharp9 commented May 7, 2019

Yeah I bake in all the attributes to get reflection to work for ProvidedUnions and ProvidedRecords in Falanx.

@realvictorprm
Copy link
Member

I just noticed, we don't have an RFC for this.

I'll dig into some stuff and see whether I can get anything together. I have the feeling this is worth having for FS-1023

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

No branches or pull requests

4 participants