This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Task[A] = IO[Throwable, A] | |
| def createMonadState[S]: Task[MonadState[Task, S]] = ??? | |
| def myLocalState[F[_]: MonadState[?, MyStateType]]: F[Boolean] = ??? | |
| for { | |
| monadState <- createMonadState[MyStateType] | |
| result <- myLocalState[MyIO](monadState) | |
| } yield result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class LoggingT[F[_], A]( | |
| run: List[String] => F[(List[String], A)]) { self => | |
| def map[B](f: A => B)(implicit F: Functor[F]): LoggingT[F, B] = | |
| LoggingT[F, B](log => self.run(log).map(t => (t._1, f(t._2)))) | |
| def flatMap[B](f: A => LoggingT[F, B])(implicit F: Monad[F]): LoggingT[F, B] = | |
| LoggingT[F, B](log => self.run(log).flatMap(t => f(t._2).run(t._1))) | |
| def eval(implicit F: Functor[F]): F[(List[String], A)] = run(Nil).map(t => (t._1.reverse, t._2)) | |
| } |
NewerOlder