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.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 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
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 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
package qiita | |
import java.util.concurrent.{ExecutorService, Executors} | |
import cats.effect._ | |
import cats.syntax.functor._ | |
import fs2.{Pipe, Stream, io, text} | |
import scala.concurrent.ExecutionContext | |
import scala.util.Try |
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
val afb0: Char => () => String = c => () => s"<$c>" | |
val ga0 = List('a', 'b') | |
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.{Kleisli, Nested, Tuple2K} | |
import cats.implicits._ | |
import cats.{Distributive, Functor, Id, Traverse, ~>} | |
// def distribute[G[_]: Functor, A, B](ga: G[A])(f: A => F[B]): F[G[B]] | |
// def cosequence[G[_]: Functor, A](ga: G[F[A]]): F[G[A]] = distribute(ga)(identity) | |
// Function0 ------------------------------ | |
// F = () => ? | |
val d0 = Distributive[() => ?] |
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.{Kleisli, Nested, Tuple2K} | |
import cats.implicits._ | |
import cats.{Distributive, Functor, Id, Traverse, ~>} | |
// def distribute[G[_]: Functor, A, B](ga: G[A])(f: A => F[B]): F[G[B]] | |
// def cosequence[G[_]: Functor, A](ga: G[F[A]]): F[G[A]] = distribute(ga)(identity) | |
// Function0 ------------------------------ | |
// F = () => ? | |
val d0 = Distributive[() => ?] |
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 java.time.LocalDate | |
import java.time.temporal.ChronoUnit.{DAYS, MONTHS} | |
import cats.instances.AllInstances | |
import cats.kernel.laws.discipline.PartialOrderTests | |
import cats.{Foldable, Monad, Monoid, PartialOrder} | |
import eu.timepit.refined.api.Refined | |
import eu.timepit.refined.numeric.Positive | |
import eu.timepit.refined.refineV | |
import org.scalacheck.{Arbitrary, Gen} |