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
import scalaz.zio.console.Console | |
import scalaz.zio._ | |
// "org.scalaz" %% "scalaz-zio" % "1.0-RC3" | |
sealed trait AppError | |
case object NoValue extends AppError | |
trait Logger { val logger: Logger.Service } | |
object Logger { |
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
import cats.FlatMap | |
import cats.data.{Chain, WriterT} | |
import cats.mtl.FunctorTell | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
import cats.data.Chain._ | |
import cats.effect.{IO, Sync} | |
import cats.mtl.instances.listen._ | |
import Chain.one |
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
import cats.FlatMap | |
import cats.data.Kleisli | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
import cats.effect.Sync | |
import cats.mtl.ApplicativeAsk | |
import monix.eval.Task | |
type Config = Map[String, String] |
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
import cats.Monad | |
import cats.data.StateT | |
import cats.effect.{IO, Sync} | |
import cats.mtl.MonadState | |
import cats.syntax.show._ | |
import cats.instances.int._ | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
import cats.syntax.applicative._ | |
import cats.syntax.traverse._ |
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
import cats.Monad | |
import cats.data.{Chain, Ior} | |
import cats.mtl.MonadChronicle | |
import cats.syntax.applicative._ | |
import cats.syntax.functor._ | |
import cats.mtl.instances.chronicle._ | |
import cats.syntax.traverse._ | |
import cats.instances.list._ | |
def func[F[_]: Monad](n: Int)(implicit F: MonadChronicle[F, Chain[Int]]): F[Int] = |
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
import cats.{FlatMap, Monad} | |
import cats.data.{Chain, WriterT} | |
import cats.effect.{IO, Sync} | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
import cats.mtl.syntax.listen._ | |
import cats.mtl.{FunctorListen, FunctorTell} | |
import Chain.one | |
type Logs = Chain[String] |
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
import cats.data.ReaderT | |
import cats.effect.IO | |
import cats.syntax.flatMap._ | |
import cats.syntax.functor._ | |
import cats.{Applicative, Monad} | |
import cats.mtl.{ApplicativeAsk, ApplicativeLocal} | |
type Config = Map[String, String] | |
def get42[F[_]: Applicative](implicit F: ApplicativeAsk[F, Config]): F[String] = |
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
import cats.mtl.FunctorRaise | |
import cats.syntax.applicative._ | |
import cats.instances.string._ | |
import cats.{Applicative, Semigroupal} | |
import cats.data.Validated | |
def parseNumber[F[_]: Applicative](in: String)(implicit F: FunctorRaise[F, String]): F[Double] = | |
if (in.matches("-?[0-9]+")) in.toDouble.pure[F] | |
else F.raise(in) // raise 構文 |
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
import cats.syntax.applicative._ | |
import cats.Applicative | |
import cats.data.Validated | |
import cats.instances.string._ | |
import cats.mtl.FunctorRaise | |
import cats.mtl.syntax.handle._ | |
import cats.mtl.instances.handle._ | |
import cats.syntax.traverse._ | |
import cats.instances.list._ |
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
import cats.data.{EitherT, State, StateT} | |
import cats.instances.either._ | |
object A { | |
type SET[E, S, R] = StateT[Either[E, ?], S, R] | |
type EST[E, S, R] = EitherT[State[S, ?], E, R] | |
def decrementSE: SET[String, Int, Unit] = for { | |
x <- StateT.get[Either[String, ?], Int] | |
_ <- if (x > 0) StateT.set[Either[String, ?], Int](x - 1) |