Skip to content

Type Lambdas Spec #5217

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

Merged
merged 7 commits into from
Oct 16, 2018
Merged

Type Lambdas Spec #5217

merged 7 commits into from
Oct 16, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 8, 2018

No description provided.

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

Some things that could be expanded on:

  • Equivalence between type Foo[A] = B and type Foo = [A] => B
  • Equivalence between def foo[M[X] <: B] and def foo[M <: [X] => B]
  • Currying (type Foo[A] = [X] => A, type Foo = [A] => [X] => A)
    • Especially the interaction with type inference which currently doesn't really work (e.g. should we do anything sensible with def foo[T, S, M <: [A] => [B] => (A, B)](x: M[T, S]) ?)
  • variance rules for the bounds of the type parameters of the lambda.

```
and two types `S <: T`, we have
```
TL1[S] <: TL1[T
Copy link
Member

Choose a reason for hiding this comment

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

missing ]

@odersky
Copy link
Contributor Author

odersky commented Oct 12, 2018

Any comments? If not let's get this in. We have lots of other parts to work on as well.

Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

Is there any subtyping relationship between parameterized class/trait kinds and corresponding type lambdas? For example, is List <: [+A] => Any?

```scala
type T >: ([X] => L) <: ([X] => U)
```
However, if `L` is `Nothing` it is not parameterized, since `Nothing` is treated as a bottom type for all kinds. For instance,
Copy link
Member

Choose a reason for hiding this comment

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

Is this exception necessary, or is it an optimization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a design choice. Whether it's necessary or not can be determined only by trying to change it and observing what breaks 😉

```
where `v1` and `v2` are optional variance annotations: `+`, `-`, or absent.
Then `TL1 <: TL2`, if the type interval `L2..U2` is contained in the type interval `L1..U1` (i.e.
`L1 <: L2` and `U2 <: U1`), and either `v2` is absent or `v1 = v2`.
Copy link
Member

Choose a reason for hiding this comment

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

The subtyping rule says nothing about R1 and R2. That looks suspicious to me. Shouldn't R1 <: R2?

@milessabin
Copy link
Contributor

I second @smarter's comment.

---
layout: doc-page
title: "Type Lambdas - More Details"
---
Copy link
Contributor

Choose a reason for hiding this comment

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

This document should be added to docs/sidebar.yml.

@odersky
Copy link
Contributor Author

odersky commented Oct 15, 2018

@nicolasstucki No, spec pages should not be part of sidebar.yml. They should be referred to from the main page of the topic.

@odersky odersky merged commit 2dd964d into scala:master Oct 16, 2018
@liufengyun liufengyun deleted the spec-type-lambdas branch October 16, 2018 09:16
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.

5 participants