-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add 0.5 docs #3579
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
Add 0.5 docs #3579
Conversation
|
||
(k: Keyed) => k.Key | ||
|
||
This type describes function values that take an argument `x` of type |
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 k
, not x
(same on the next line)
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.
No, k
is the parameter. I wanted to use a different name for the argument.
A dependent function type describes functions where the result type may depend | ||
on the function's parameter values. Example: | ||
|
||
class Keyed { type Key; key: Key } |
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.
Keyed
and Key
are a bit too easy to confuse when following the example. I would maybe replace Keyed
by Entry
.
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.
OK, let's do this.
|
||
This query would now be classified as ambiguous. This makes sense, after all | ||
there are two possible solutions, `b(a1)` and `b(a2)`, neither of which is better | ||
than the other and both of which are better than the third solution, `c`. |
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.
Why are b(a1)
and b(a2)
better than c
?
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.
because their return type is a subtype is of the return type of c
and the query `implicitly[C]`. | ||
|
||
This query would now be classified as ambiguous. This makes sense, after all | ||
there are two possible solutions, `b(a1)` and `b(a2)`, neither of which is better |
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.
3 solutions?
type refers to some of the parameters of the method. Method | ||
`extractKey` is an example. Its result type, `k.key` refers its | ||
parameter `k` (we also say, `k.Key` _depends_ on `k`). But so far it | ||
was not possible to turn such methods into function values, so thay |
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.
so that
def apply(x1: K1, ..., xN: KN): R | ||
} | ||
|
||
where the result type parameter `R` is an upper approximation of the |
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.
R'
?
They do not work in code, which is where we would have needed them.
@@ -0,0 +1,50 @@ | |||
--- | |||
layout: doc-page`% | |||
title: "Dependent`% Function Types" |
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.
What is the `%
for?
there are two possible solutions, `b(a1)` and `b(a2)`, neither of which is better | ||
than the other and both of which are better than the third solution, `c`. | ||
By contrast, Scala 2 would have rejected the search for `A` as | ||
ambiguous, and subsequently have classified the query `b(implictly[A])` as a normal fail, |
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.
Typo 'implictly'
No description provided.