Skip to content

Commit

Permalink
workaround for tut and Scala 2.13.0-M5
Browse files Browse the repository at this point in the history
  • Loading branch information
larsrh committed Feb 13, 2019
1 parent d744fd0 commit 1e89758
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions docs/src/main/tut/mtl-classes/applicativehandle.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import cats.implicits._
import cats.mtl._
import cats.mtl.implicits._
// The function which might raise an error
def parseNumber[F[_]: Applicative](in: String)(implicit F: FunctorRaise[F, String]): F[Int] = {
// this function might raise an error
if (in.matches("-?[0-9]+")) in.toInt.pure[F]
else F.raise(show"'$in' could not be parsed as a number")
}
Expand Down
14 changes: 7 additions & 7 deletions docs/src/main/tut/mtl-classes/functorlisten.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import cats.implicits._
import cats.mtl._
import cats.mtl.implicits._
// impure implementation for demonstrative purposes, please don't do this at home
def sendToServer[F[_]: Monad](logs: Chain[String]): F[Unit] =
// impure implementation for demonstrative purposes, please don't do this at home
Monad[F].pure(println(show"Sending to server: $logs"))
def sendLogsToServer[F[_]: Monad, A](logProgram: F[A])(implicit F: FunctorListen[F, Chain[String]]): F[A] =
logProgram.listen.flatMap {
case (a, logs) => sendToServer[F](logs).as(a)
Expand All @@ -39,11 +38,12 @@ To see if it works, let's write some logging program and run it all with `Writer

```tut:book
// Example of some logging activity in your application
def logging[F[_]: Monad](implicit F: FunctorTell[F, Chain[String]]): F[Unit] = for {
_ <- F.tell(Chain.one("First log"))
_ <- F.tell(Chain.one("Second log"))
} yield ()
def logging[F[_]: Monad](implicit F: FunctorTell[F, Chain[String]]): F[Unit] =
// Example of some logging activity in your application
for {
_ <- F.tell(Chain.one("First log"))
_ <- F.tell(Chain.one("Second log"))
} yield ()
val result = sendLogsToServer(logging[Writer[Chain[String], ?]]).value
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/mtl-classes/functortell.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ case class ServiceParams(option1: String, option2: Int)
case class ServiceResult(userId: Int, companies: List[String])
// a fake call to some external service, replace with real implementation
def serviceCall[F[_]: Monad](params: ServiceParams): F[ServiceResult] =
// a fake call to some external service, replace with real implementation
ServiceResult(0, List("Raven Enterprises")).pure[F]
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/mtl-classes/monadstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import cats.mtl.implicits._
case class ServiceResult(id: Int, companies: List[String])
// a fake call to some external service, impure, so don't do this at home!
def serviceCall[F[_]: Monad](id: String): F[ServiceResult] = {
// a fake call to some external service, impure, so don't do this at home!
println(show"Called service with $id")
ServiceResult(0, List("Raven Enterprises")).pure[F]
}
Expand Down

0 comments on commit 1e89758

Please sign in to comment.