@@ -27,15 +27,15 @@ trait Monoid[T] extends SemiGroup[T] {
2727An 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
3636Whereas 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
9898This 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[_]] {
130130The 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
175175Let 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