diff --git a/docs/docs/reference/contextual/derivation.md b/docs/docs/reference/contextual/derivation.md index b43efd4844e9..3186b26c3042 100644 --- a/docs/docs/reference/contextual/derivation.md +++ b/docs/docs/reference/contextual/derivation.md @@ -40,7 +40,7 @@ The generated typeclass instances are placed in the companion objects `Labelled` A trait or class can appear in a `derives` clause if its companion object defines a method named `derived`. The type and implementation of a `derived` method are arbitrary, but typically it has a definition like this: ```scala - def derived[T] with Generic[T] = ... + def derived[T] given Generic[T] = ... ``` That is, the `derived` method takes an inferable parameter of type `Generic` that determines the _shape_ of the deriving type `T` and it computes the typeclass implementation according to that shape. An implied `Generic` instance is generated automatically for any type that derives a typeclass with a `derived` method that refers to `Generic`. One can also derive `Generic` alone, which means a `Generic` instance is generated without any other type class instances. E.g.: @@ -218,7 +218,7 @@ trait Eq[T] { We need to implement a method `Eq.derived` that produces an instance of `Eq[T]` provided there exists evidence of type `Generic[T]`. Here's a possible solution: ```scala - inline def derived[T] with (ev: Generic[T]): Eq[T] = new Eq[T] { + inline def derived[T] given (ev: Generic[T]): Eq[T] = new Eq[T] { def eql(x: T, y: T): Boolean = { val mx = ev.reflect(x) // (1) val my = ev.reflect(y) // (2) @@ -315,7 +315,7 @@ calling the `error` method defined in `scala.compiletime`. **Example:** Here is a slightly polished and compacted version of the code that's generated by inline expansion for the derived `Eq` instance of class `Tree`. ```scala -implied [T] with (elemEq: Eq[T]) for Eq[Tree[T]] { +implied [T] given (elemEq: Eq[T]) for Eq[Tree[T]] { def eql(x: Tree[T], y: Tree[T]): Boolean = { val ev = the[Generic[Tree[T]]] val mx = ev.reflect(x)