From 1e89758b505ad7f39b4421f15041bad201e53d27 Mon Sep 17 00:00:00 2001 From: Lars Hupel Date: Wed, 13 Feb 2019 14:02:12 +0100 Subject: [PATCH] workaround for tut and Scala 2.13.0-M5 --- docs/src/main/tut/mtl-classes/applicativehandle.md | 3 +-- docs/src/main/tut/mtl-classes/functorlisten.md | 14 +++++++------- docs/src/main/tut/mtl-classes/functortell.md | 2 +- docs/src/main/tut/mtl-classes/monadstate.md | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/src/main/tut/mtl-classes/applicativehandle.md b/docs/src/main/tut/mtl-classes/applicativehandle.md index 1c3118e0..332041c3 100644 --- a/docs/src/main/tut/mtl-classes/applicativehandle.md +++ b/docs/src/main/tut/mtl-classes/applicativehandle.md @@ -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") } diff --git a/docs/src/main/tut/mtl-classes/functorlisten.md b/docs/src/main/tut/mtl-classes/functorlisten.md index 208da1de..3a3e7d04 100644 --- a/docs/src/main/tut/mtl-classes/functorlisten.md +++ b/docs/src/main/tut/mtl-classes/functorlisten.md @@ -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) @@ -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 ``` diff --git a/docs/src/main/tut/mtl-classes/functortell.md b/docs/src/main/tut/mtl-classes/functortell.md index 245447c2..cf87b412 100644 --- a/docs/src/main/tut/mtl-classes/functortell.md +++ b/docs/src/main/tut/mtl-classes/functortell.md @@ -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] ``` diff --git a/docs/src/main/tut/mtl-classes/monadstate.md b/docs/src/main/tut/mtl-classes/monadstate.md index 011de5ae..be06e157 100644 --- a/docs/src/main/tut/mtl-classes/monadstate.md +++ b/docs/src/main/tut/mtl-classes/monadstate.md @@ -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] }