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.arrow.Profunctor | |
import cats.data.Kleisli | |
import eu.timepit.refined.api.Refined | |
import eu.timepit.refined.boolean.Not | |
import eu.timepit.refined.generic.Equal | |
import eu.timepit.refined.string.MatchesRegex | |
import eu.timepit.refined.{W, refineMV, refineV} | |
import shapeless.Nat._0 | |
import cats.instances.function._ | |
import cats.syntax.profunctor._ |
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
def measure(f: => Int): (Int, Long) = { | |
val start = System.currentTimeMillis() | |
val result = f | |
val millis = System.currentTimeMillis() - start | |
(result, millis) | |
} | |
def tarai(x: Int, y: Int, z: Int): Int = | |
if (x <= y) y else tarai(tarai(x - 1, y, z), | |
tarai(y - 1, z, x), |
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 shapeless._ | |
import shapeless.ops.hlist._ | |
object typeChainCat { | |
trait Id[A] { | |
type Out | |
def apply(l: A): Out | |
} | |
object Id { | |
type Aux[L, O] = Id[L] { type Out = O } |
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, Writer} | |
import cats.free.Free | |
import cats.~> | |
// domain layer ----------------------------------------------------------- | |
case class Movie(id: Int, title: String) | |
sealed trait Query[A] | |
case class GetMovie(id: Int) extends Query[Option[Movie]] | |
type QueryF[T] = Free[Query, T] |
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.free.Free.liftF | |
import cats.free.Free | |
import cats.{Id, ~>} | |
// domain layer ----------------------------------------------------------- | |
case class Movie(id: Int, title: String) | |
sealed trait Query[A] | |
case class GetMovie(id: Int) extends Query[Option[Movie]] |
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.option._ | |
// domain layer ----------------------------------------------------------- | |
import monix.eval.Task | |
import cats.data.ReaderT | |
case class Movie(id: Int, title: String) | |
trait MovieRepo { | |
def getMovie(id: Int): Task[Option[Movie]] |
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.option._ | |
// domain layer ----------------------------------------------------------- | |
import monix.eval.Task | |
case class Movie(id: Int, title: String) | |
trait MovieRepo { | |
def getMovie(id: Int): Task[Option[Movie]] | |
} |
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.option._ | |
// domain layer ----------------------------------------------------------- | |
import monix.eval.Task | |
case class Movie(id: Int, title: String) | |
trait MovieRepoComponent { | |
trait MovieRepo { | |
def getMovie(id: Int): Task[Option[Movie]] | |
} |
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.Monoid | |
import cats.arrow.Arrow | |
import cats.data.Kleisli | |
sealed case class SimpleFunc[A, B](runF: A => B) | |
import cats.syntax.arrow._ | |
import cats.syntax.compose._ | |
def arr[F[_, _]: Arrow, A, B](f: A => B): F[A, B] = Arrow[F] lift f |
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.arrow.Arrow | |
import cats.data.Kleisli | |
sealed case class SimpleFunc[A, B](runF: A => B) | |
import cats.syntax.arrow._ | |
import cats.syntax.compose._ | |
def arr[F[_, _]: Arrow, A, B](f: A => B): F[A, B] = Arrow[F] lift f | |
def split[F[_, _]: Arrow, A]: F[A, (A, A)] = arr(x => (x, x)) |