Skip to content

Commit 34953cd

Browse files
committed
Adjust more examples with the new implicits, renames and update doc urls
1 parent 0c01817 commit 34953cd

13 files changed

+28
-28
lines changed

src/main/scala/AutoParamTupling.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
/**
3-
* Automatic Tupling of Function Params: http://dotty.epfl.ch/docs/reference/auto-parameter-tupling.html
3+
* Automatic Tupling of Function Params: https://dotty.epfl.ch/docs/reference/other-new-features/auto-parameter-tupling.html
44
*/
55
object AutoParamTupling {
66

77
def test: Unit = {
88

99
/**
1010
* In order to get thread safety, you need to put @volatile before lazy vals.
11-
* http://dotty.epfl.ch/docs/reference/changed/lazy-vals.html
11+
* https://dotty.epfl.ch/docs/reference/changed-features/lazy-vals.html
1212
*/
1313
@volatile lazy val xs: List[String] = List("d", "o", "t", "t", "y")
1414

src/main/scala/ContextQueries.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ object ContextQueries /* Formerly known as Implicit Function Types */ {
2121

2222
object parse {
2323

24-
type Parseable[T] = given ImplicitParams.StringParser[T] => Try[T]
24+
type Parseable[T] = given ImpliedInstances.StringParser[T] => Try[T]
2525

2626
def sumStrings(x: String, y: String): Parseable[Int] = {
27-
val parser = implicitly[ImplicitParams.StringParser[Int]]
27+
val parser = implicitly[ImpliedInstances.StringParser[Int]]
2828
val tryA = parser.parse(x)
2929
val tryB = parser.parse(y)
3030

src/main/scala/EnumTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Enum Types: http://dotty.epfl.ch/docs/reference/adts.html
2+
* Enum Types: http://dotty.epfl.ch/docs/reference/enums/adts.html
33
*/
44
object EnumTypes {
55

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import scala.util.{Success, Try}
22

33
/**
4-
* Implicit By-Name Parameters:
5-
* - http://dotty.epfl.ch/docs/reference/implicit-by-name-parameters.html
4+
* Implied Instances:
5+
* - https://dotty.epfl.ch/docs/reference/contextual/instance-defs.html
66
*/
7-
object ImplicitParams {
7+
object ImpliedInstances {
88

99
sealed trait StringParser[A] {
1010
def parse(s: String): Try[A]
1111
}
1212

1313
object StringParser {
1414

15-
def apply[A](implicit parser: StringParser[A]): StringParser[A] = parser
15+
def apply[A] given (parser: StringParser[A]): StringParser[A] = parser
1616

1717
private def baseParser[A](f: String Try[A]): StringParser[A] = new StringParser[A] {
1818
override def parse(s: String): Try[A] = f(s)
1919
}
2020

21-
implicit val stringParser: StringParser[String] = baseParser(Success(_))
22-
implicit val intParser: StringParser[Int] = baseParser(s Try(s.toInt))
21+
implied stringParser for StringParser[String] = baseParser(Success(_))
22+
implied intParser for StringParser[Int] = baseParser(s Try(s.toInt))
2323

24-
implicit def optionParser[A](implicit parser: => StringParser[A]): StringParser[Option[A]] = new StringParser[Option[A]] {
24+
implied optionParser[A] given (parser: => StringParser[A]) for StringParser[Option[A]] = new StringParser[Option[A]] {
2525
override def parse(s: String): Try[Option[A]] = s match {
2626
case "" Success(None) // implicit parser not used.
2727
case str parser.parse(str).map(x Some(x)) // implicit parser is evaluated at here
@@ -34,6 +34,6 @@ object ImplicitParams {
3434
println(implicitly[StringParser[Option[Int]]].parse(""))
3535
println(implicitly[StringParser[Option[Int]]].parse("21a"))
3636

37-
println(implicitly[StringParser[Option[Int]]](StringParser.optionParser[Int](StringParser.intParser)).parse("42"))
37+
println(implicitly[StringParser[Option[Int]]](StringParser.optionParser[Int]).parse("42"))
3838
}
3939
}

src/main/scala/IntersectionTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Intersection Types: http://dotty.epfl.ch/docs/reference/intersection-types.html
2+
* Intersection Types: https://dotty.epfl.ch/docs/reference/new-types/intersection-types.html
33
*/
44
object IntersectionTypes {
55

src/main/scala/Main.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Main {
99

1010
runExample("Context Queries")(ContextQueries.test)
1111

12-
runExample("Implicit Params")(ImplicitParams.test)
12+
runExample("Implied Instances")(ImpliedInstances.test)
1313

1414
runExample("Conversion")(Conversion.test)
1515

src/main/scala/MultiversalEquality.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ object MultiversalEquality {
99
def test: Unit = {
1010

1111
// Values of types Int and String cannot be compared with == or !=,
12-
// unless we add a custom implicit like:
13-
implicit def eqIntString: Eql[Int, String] = Eql.derived
12+
// unless we add the derived implied instance like:
13+
implied for Eql[Int, String] = Eql.derived
1414
println(3 == "3")
1515

1616
// By default, all numbers are comparable, because of;
17-
// implicit def eqNumber : Eq[Number, Number] = Eq
17+
// implicit def eqlNumber: Eql[Number, Number] = derived
1818
println(3 == 5.1)
1919

2020
// By default, all Sequences are comparable, because of;
21-
// implicit def eqSeq[T, U](implicit eq: Eq[T, U]): Eq[Seq[T], Seq[U]] = Eq
21+
// implicit def eqlSeq[T, U](implicit eq: Eql[T, U]): Eql[GenSeq[T], GenSeq[U]] = derived
2222
println(List(1, 2) == Vector(1, 2))
2323

2424
class A(a: Int)
@@ -27,10 +27,10 @@ object MultiversalEquality {
2727
val a = new A(4)
2828
val b = new B(4)
2929

30-
// scala.language.strictEquality is enabled, therefore we need some extra implicits
30+
// scala.language.strictEquality is enabled, therefore we need some extra implied instances
3131
// to compare instances of A and B.
32-
implicit def eqAB: Eql[A, B] = Eql.derived
33-
implicit def eqBA: Eql[B, A] = Eql.derived
32+
implied for Eql[A, B] = Eql.derived
33+
implied for Eql[B, A] = Eql.derived
3434

3535
println(a != b)
3636
println(b == a)

src/main/scala/NamedTypeArguments.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* Named Type Arguments: http://dotty.epfl.ch/docs/reference/named-typeargs.html
3+
* Named Type Arguments: https://dotty.epfl.ch/docs/reference/other-new-features/named-typeargs.html
44
*/
55
object NamedTypeArguments {
66

src/main/scala/PatternMatching.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* Pattern Matching: http://dotty.epfl.ch/docs/reference/changed/pattern-matching.html
3+
* Pattern Matching: https://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html
44
*/
55
object PatternMatching {
66

src/main/scala/StructuralTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* Structural Types: http://dotty.epfl.ch/docs/reference/changed/structural-types.html
3+
* Structural Types: https://dotty.epfl.ch/docs/reference/changed-features/structural-types.html
44
*/
55
object StructuralTypes {
66

src/main/scala/TraitParams.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Trait Parameters: http://dotty.epfl.ch/docs/reference/trait-parameters.html
2+
* Trait Parameters: https://dotty.epfl.ch/docs/reference/other-new-features/trait-parameters.html
33
*/
44
object TraitParams {
55

src/main/scala/TypeLambdas.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Type Lambdas: http://dotty.epfl.ch/docs/reference/type-lambdas.html
2+
* Type Lambdas: https://dotty.epfl.ch/docs/reference/new-types/type-lambdas.html
33
*/
44
object TypeLambdas {
55

src/main/scala/UnionTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Union Types: http://dotty.epfl.ch/docs/reference/union-types.html
2+
* Union Types: https://dotty.epfl.ch/docs/reference/new-types/union-types.html
33
*/
44
object UnionTypes {
55

0 commit comments

Comments
 (0)