-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Type Lambdas Spec #5217
Conversation
There was a problem hiding this 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
andtype Foo = [A] => B
- Equivalence between
def foo[M[X] <: B]
anddef 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])
?)
- Especially the interaction with type inference which currently doesn't really work (e.g. should we do anything sensible with
- variance rules for the bounds of the type parameters of the lambda.
``` | ||
and two types `S <: T`, we have | ||
``` | ||
TL1[S] <: TL1[T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing ]
Any comments? If not let's get this in. We have lots of other parts to work on as well. |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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
?
I second @smarter's comment. |
--- | ||
layout: doc-page | ||
title: "Type Lambdas - More Details" | ||
--- |
There was a problem hiding this comment.
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
.
@nicolasstucki No, spec pages should not be part of sidebar.yml. They should be referred to from the main page of the topic. |
No description provided.