Skip to content

Commit 4b04603

Browse files
author
Arnaud ESTEVE
committed
Proper 0.23 syntax
1 parent df15a24 commit 4b04603

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/docs/reference/contextual/typeclasses-new.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ trait Monoid[T] extends SemiGroup[T] {
2727
An implementation of this `Monoid` typeclass for the type `String` can be the following:
2828

2929
```scala
30-
givenMonoid[String] {
30+
given Monoid[String] {
3131
def (x: String) combine (y: String): String = x.concat(y)
3232
def unit: String = ""
3333
}
3434
```
3535

3636
Whereas for the type `Int` one could write the following:
3737
```scala
38-
givenMonoid[Int] {
38+
given Monoid[Int] {
3939
def (x: Int) combine (y: Int): Int = x + y
4040
def unit: Int = 0
4141
}
@@ -98,7 +98,7 @@ Which could read as follows: "A `Functor` for the type constructor `F[_]` repres
9898
This way, we could define an instance of `Functor` for the `List` type:
9999

100100
```scala
101-
givenFunctor[List] {
101+
given Functor[List] {
102102
def map[A, B](original: List[A], mapper: A => B): List[B] =
103103
original.map(mapper) // List already has a `map` method
104104
}
@@ -130,7 +130,7 @@ trait Functor[F[_]] {
130130
The instance of `Functor` for `List` now becomes:
131131

132132
```scala
133-
givenFunctor[List] {
133+
given Functor[List] {
134134
def [A, B](original: List[A]).map(mapper: A => B): List[B] =
135135
original.map(mapper) // List already has a `map` method
136136
}
@@ -174,7 +174,7 @@ trait Monad[F[_]] extends Functor[F] { // "A `Monad` for type `F[_]` is a `Funct
174174

175175
Let us declare the `Monad` ability for type `List`
176176
```scala
177-
given listMonad as Monad[List] {
177+
given listMonad: Monad[List] {
178178
def pure[A](x: A): List[A] =
179179
List(x)
180180
def [A, B](xs: List[A]).flatMap(f: A => List[B]): List[B] =
@@ -192,7 +192,7 @@ given listMonad as Monad[List] {
192192
* the `pure` ability turning `A` into `Option[A]`
193193

194194
```scala
195-
given optionMonad as Monad[Option] {
195+
given optionMonad: Monad[Option] {
196196
def pure[A](x: A): Option[A] =
197197
Option(x)
198198
def [A, B](xs: Option[A]).flatMap(f: A => Option[B]): Option[B] =

0 commit comments

Comments
 (0)