-
Notifications
You must be signed in to change notification settings - Fork 825
Open
Open
Copy link
Milestone
Description
This spans from the discussion of fsharp/fslang-suggestions#538 "Erased type-tagged anonymous union types", which is from 2017 and not seeming to be implemented.
I actually like the simpler idea by @voronoipotato in his comment, because that sounds very implentable. And that's not a language feature, but just a minor addition to FSharp.Core and compiler.
-
Why not to add
[<ErasedAttribute>]
to F# core?- Definition: It's an instruction to the compiler that the type can be simplified by compile-time reduction.
- What it actually does in practice depends on the compiler target (IL/JS/...)
- Fable can replace its attribute with FSharp.Core version.
-
As the first traditional F# compiler, the feature would be: Remove tagged single-case DUs:
[<Erased>] type Phone = | Phone of string
could compile intostring
- Benefit: Provide simpler C# interopability usage.
- Benefit: Provide more performant runtime execution while still maintaining the type safety for the developer.
- A compile-time thing, a little bit like ReflectedDefinitionAttribute. If a user breaks their own code with it (e.g. calling the type via another F# dll via ProjectReference instead of NuGet/dll-reference), it's their own problem. (Could it be erased in whole sln or is that too complex?)
voronoipotato
Metadata
Metadata
Assignees
Type
Projects
Status
New