@@ -27,15 +27,15 @@ trait Monoid[T] extends SemiGroup[T] {
27
27
An implementation of this ` Monoid ` typeclass for the type ` String ` can be the following:
28
28
29
29
``` scala
30
- givenMonoid [String ] {
30
+ given Monoid [String ] {
31
31
def (x : String ) combine (y : String ): String = x.concat(y)
32
32
def unit : String = " "
33
33
}
34
34
```
35
35
36
36
Whereas for the type ` Int ` one could write the following:
37
37
``` scala
38
- givenMonoid [Int ] {
38
+ given Monoid [Int ] {
39
39
def (x : Int ) combine (y : Int ): Int = x + y
40
40
def unit : Int = 0
41
41
}
@@ -98,7 +98,7 @@ Which could read as follows: "A `Functor` for the type constructor `F[_]` repres
98
98
This way, we could define an instance of ` Functor ` for the ` List ` type:
99
99
100
100
``` scala
101
- givenFunctor [List ] {
101
+ given Functor [List ] {
102
102
def map [A , B ](original : List [A ], mapper : A => B ): List [B ] =
103
103
original.map(mapper) // List already has a `map` method
104
104
}
@@ -130,7 +130,7 @@ trait Functor[F[_]] {
130
130
The instance of ` Functor ` for ` List ` now becomes:
131
131
132
132
``` scala
133
- givenFunctor [List ] {
133
+ given Functor [List ] {
134
134
def [A , B ](original : List [A ]).map(mapper : A => B ): List [B ] =
135
135
original.map(mapper) // List already has a `map` method
136
136
}
@@ -174,7 +174,7 @@ trait Monad[F[_]] extends Functor[F] { // "A `Monad` for type `F[_]` is a `Funct
174
174
175
175
Let us declare the ` Monad ` ability for type ` List `
176
176
``` scala
177
- given listMonad as Monad [List ] {
177
+ given listMonad : Monad [List ] {
178
178
def pure [A ](x : A ): List [A ] =
179
179
List (x)
180
180
def [A , B ](xs : List [A ]).flatMap(f : A => List [B ]): List [B ] =
@@ -192,7 +192,7 @@ given listMonad as Monad[List] {
192
192
* the ` pure ` ability turning ` A ` into ` Option[A] `
193
193
194
194
``` scala
195
- given optionMonad as Monad [Option ] {
195
+ given optionMonad : Monad [Option ] {
196
196
def pure [A ](x : A ): Option [A ] =
197
197
Option (x)
198
198
def [A , B ](xs : Option [A ]).flatMap(f : A => Option [B ]): Option [B ] =
0 commit comments