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 type_classes.partialorder | |
import cats.PartialOrder | |
import cats.syntax.partialOrder._ | |
import cats.instances.AllInstances | |
import cats.kernel.BoundedSemilattice | |
import cats.kernel.laws.discipline.{BoundedSemilatticeTests, PartialOrderTests} | |
import org.scalacheck.{Arbitrary, Gen} | |
import org.specs2.Specification | |
import org.typelevel.discipline.specs2.Discipline |
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.MonoidK | |
import scala.util.Try | |
import cats.data.Kleisli | |
import cats.syntax.option._ | |
import cats.syntax.either._ | |
import cats.syntax.compose._ | |
import cats.syntax.foldable._ | |
import cats.syntax.arrow._ | |
import cats.syntax.arrowChoice._ |
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.ops.hlist.{Length, Repeat} | |
import shapeless.{::, Generic, HList, HNil, Nat} | |
case class IceCream(name: String, numCherries: Int, inCone: Boolean) | |
def repeat[I <: HList, L <: Nat, O <: HList](in: I, s: String)( | |
implicit | |
len: Length.Aux[I, L], | |
rep: Repeat.Aux[String :: HNil, L, O] | |
): O = rep(s :: HNil) |
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.Nat._ | |
import shapeless.ops.nat.ToInt | |
import shapeless.syntax.sized._ | |
import shapeless.{Nat, Sized} | |
type Vect[N <: Nat] = Sized[IndexedSeq[Int], N] | |
def vect = Sized.apply[IndexedSeq] | |
def times[L <: Nat](k: Int, v1: Vect[L]): Vect[L] = v1.map(_ * k) |
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.ops.coproduct.{IsCCons, Selector, Unifier} | |
import shapeless.{:+:, CNil, Coproduct} | |
// Party Types ------------------------- | |
sealed trait PartyType | |
sealed trait Region extends PartyType | |
sealed trait Division extends PartyType | |
sealed trait Doctor extends PartyType |
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.{Id, Monad} | |
// domain layer ------------------------------------------------------ | |
case class Movie(id: Int, title: String) | |
trait MovieRepoSym[F[_]] { | |
def getMovie(id: Int): F[Option[Movie]] | |
} | |
class MovieService[F[_]: Monad](sym: MovieRepoSym[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.data.Chain | |
// domain layer ----------------------------------------------------------- | |
case class Movie(id: Int, title: String) | |
trait MovieRepo[F[_]] { | |
def getMovie(id: Int): F[Option[Movie]] | |
} | |
trait UsesMovieRepo[F[_]] { | |
val movieRepo: MovieRepo[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.free.Free | |
import cats.free.Free.liftF | |
import cats.~> | |
// 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.free.Free | |
import cats.free.Free.liftF | |
import cats.{Id, Monad, ~>} | |
import cats.syntax.option._ | |
// 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.free.Free | |
import cats.free.Free.liftF | |
import cats.~> | |
// domain layer ----------------------------------------------------------- | |
case class Movie(id: Int, title: String) | |
sealed trait Query[A] | |
case class GetMovie(id: Int) extends Query[Option[Movie]] |