Skip to content

Commit 466bff9

Browse files
author
Arnaud ESTEVE
committed
Adapt to 0.23 latest
1 parent 9c1509b commit 466bff9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/docs/reference/contextual/typeclasses.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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: Monad[List] {
177+
given listMonad as 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: Monad[List] {
192192
* the `pure` ability turning `A` into `Option[A]`
193193

194194
```scala
195-
given optionMonad: Monad[Option] {
195+
given optionMonad as 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] =
@@ -209,6 +209,7 @@ Let us have a `Config` type, and two functions using it:
209209

210210
```scala
211211
trait Config
212+
// ...
212213
def compute(i: Int)(config: Config): String = ???
213214
def show(str: String)(config: Config): Unit = ???
214215
```
@@ -230,11 +231,12 @@ type ConfigDependent[Result] = Config => Result
230231
The monad will look like this:
231232

232233
```scala
233-
given configDependentMonad as Monad[ConfigDependent]
234+
given configDependentMonad as Monad[ConfigDependent] {
234235
def [A, B](r: ConfigDependent[A]).flatMap(f: A => ConfigDependent[B]): ConfigDependent[B] =
235236
config => f(r(config))(config)
236237
def pure[A](x: A): ConfigDependent[A] =
237238
config => x
239+
}
238240
```
239241

240242
The type `ConfigDependent` can be written using [type lambdas](../new-types/type-lambdas.html):

0 commit comments

Comments
 (0)