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

FS-1006 struct tuples #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Martin521
Copy link
Contributor

Added "struct tuples" according to FS-1006 to the types, expressions, patterns and inference chapters.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
Martin521 Martin
@edgarfgp
Copy link
Member

@T-Gro Any change we can get a review.

@@ -355,6 +365,9 @@ example, `typeof<int * int>` is equivalent to `typeof<System.Tuple<int,int>>`, a
runtime type `System.Tuple<int,int>`. Likewise, `(1,2,3,4,5,6,7,8,9)` has the runtime type
`Tuple<int,int,int,int,int,int,int,Tuple<int,int>>`.

Tuple types and expressions that have `S` resolved to struct tuple are translated in the same way to `System.StructTuple`.


> Note: The above encoding is invertible and the substitution of types for type variables
preserves this inversion. This means, among other things, that the F# reflection library
can correctly report tuple types based on runtime System.Type values. The inversion is
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
can correctly report tuple types based on runtime System.Type values. The inversion is
can correctly report tuple types based on runtime System.Type and System.ValueTuple values. The inversion is

@@ -355,6 +365,9 @@ example, `typeof<int * int>` is equivalent to `typeof<System.Tuple<int,int>>`, a
runtime type `System.Tuple<int,int>`. Likewise, `(1,2,3,4,5,6,7,8,9)` has the runtime type
`Tuple<int,int,int,int,int,int,int,Tuple<int,int>>`.

Tuple types and expressions that have `S` resolved to struct tuple are translated in the same way to `System.StructTuple`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Tuple types and expressions that have `S` resolved to struct tuple are translated in the same way to `System.StructTuple`.
Tuple types and expressions that have `S` resolved to struct tuple are translated in the same way to [System.ValueTuple](https://learn.microsoft.com/dotnet/api/system.valuetuple) .


A _struct tuple expression_ is checked in the same way as a _tuple expression_, but the pseudo-type `S` is resolved to struct tuple.

Tuple types and expressions that have `S` resolved to reference tuple are translated into applications of a family of F# library types named
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Tuple types and expressions that have `S` resolved to reference tuple are translated into applications of a family of F# library types named
Tuple types and expressions that have `S` resolved to reference tuple are translated into applications of a family of .NET types named

A _struct tuple expression_ is checked in the same way as a _tuple expression_, but the pseudo-type `S` is resolved to struct tuple.

Tuple types and expressions that have `S` resolved to reference tuple are translated into applications of a family of F# library types named
`System.Tuple`. Tuple types `ty1 * ... * tyn` are translated as follows:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`System.Tuple`. Tuple types `ty1 * ... * tyn` are translated as follows:
[System.Tuple](https://learn.microsoft.com/dotnet/api/system.tuple). Tuple types `ty1 * ... * tyn` are translated as follows:

struct ( ty 1 * ... * tyn )
```

The elaborated form of a tuple type is shorthand for a use of the family of F# library types
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The elaborated form of a tuple type is shorthand for a use of the family of F# library types
The elaborated form of a tuple type is shorthand for a use of the family of .NET types

```

The elaborated form of a tuple type is shorthand for a use of the family of F# library types
`System.StructTuple<_, ..., _>`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`System.StructTuple<_, ..., _>`.
[System.ValueTuple](https://learn.microsoft.com/dotnet/api/system.valuetuple).


When considered as static types, tuple types are distinct from their encoded form. However, the
encoded form of tuple types is visible in the F# type system through runtime types. For example,
`typeof<int * int>` is equivalent to `typeof<System.StructTuple<int,int>>`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`typeof<int * int>` is equivalent to `typeof<System.StructTuple<int,int>>`.
`typeof<int * int>` is equivalent to `typeof<System.ValueTuple<int,int>>`.

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

Successfully merging this pull request may close these issues.

None yet

3 participants