@@ -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 : Monad [List ] {
177
+ given listMonad as 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: Monad[List] {
192
192
* the ` pure ` ability turning ` A ` into ` Option[A] `
193
193
194
194
``` scala
195
- given optionMonad : Monad [Option ] {
195
+ given optionMonad as 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 ] =
@@ -209,6 +209,7 @@ Let us have a `Config` type, and two functions using it:
209
209
210
210
``` scala
211
211
trait Config
212
+ // ...
212
213
def compute (i : Int )(config : Config ): String = ???
213
214
def show (str : String )(config : Config ): Unit = ???
214
215
```
@@ -230,11 +231,12 @@ type ConfigDependent[Result] = Config => Result
230
231
The monad will look like this:
231
232
232
233
``` scala
233
- given configDependentMonad as Monad [ConfigDependent ]
234
+ given configDependentMonad as Monad [ConfigDependent ] {
234
235
def [A , B ](r : ConfigDependent [A ]).flatMap(f : A => ConfigDependent [B ]): ConfigDependent [B ] =
235
236
config => f(r(config))(config)
236
237
def pure [A ](x : A ): ConfigDependent [A ] =
237
238
config => x
239
+ }
238
240
```
239
241
240
242
The type ` ConfigDependent ` can be written using [ type lambdas] ( ../new-types/type-lambdas.html ) :
0 commit comments