Skip to content

Commit

Permalink
Bump stuff (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
notxcain committed Nov 8, 2019
1 parent 99e10e2 commit 59bd183
Show file tree
Hide file tree
Showing 28 changed files with 93 additions and 97 deletions.
17 changes: 6 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ lazy val jsr305Version = "3.0.2"
lazy val boopickleVersion = "1.3.1"
lazy val monocleVersion = "2.0.0"

lazy val fs2Version = "2.0.1"
lazy val fs2Version = "2.1.0"
lazy val scodecBitsVersion = "1.1.12"
lazy val scodecCoreVersion = "1.11.4"

lazy val catsTaglessVersion = "0.10"

lazy val scalaCheckVersion = "1.14.2"
lazy val scalaTestVersion = "3.1.0-SNAP13"
lazy val scalatestplusScalaCheckVersion = "1.0.0-M2"
lazy val scalatestPlusScalaCheckVersion = "3.1.0.0-RC2"
lazy val scalaCheckShapelessVersion = "1.2.3"
lazy val disciplineVersion = "0.12.0-M3"
lazy val disciplineScalatestVersion = "1.0.0-RC1"
lazy val embeddedKafkaVersion = "2.3.0"
lazy val shapelessVersion = "2.3.3"
lazy val kindProjectorVersion = "0.10.3"
Expand All @@ -41,7 +39,7 @@ lazy val betterMonadicForVersion = "0.3.1"
// Example dependencies

lazy val circeVersion = "0.12.3"
lazy val http4sVersion = "0.21.0-M4"
lazy val http4sVersion = "0.21.0-M5"
lazy val log4catsVersion = "0.3.0"
lazy val catsMTLVersion = "0.7.0"

Expand Down Expand Up @@ -200,7 +198,6 @@ lazy val kafkaDistributedProcessingSettings = Seq(
"org.apache.kafka" % "kafka-clients" % apacheKafkaClientsVersion,
"co.fs2" %% "fs2-core" % fs2Version,
"co.fs2" %% "fs2-reactive-streams" % fs2Version,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"io.github.embeddedkafka" %% "embedded-kafka" % embeddedKafkaVersion % Test
)
)
Expand Down Expand Up @@ -262,11 +259,9 @@ lazy val testsSettings = Seq(

lazy val commonTestSettings = Seq(
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % scalaCheckVersion % Test,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % scalaCheckShapelessVersion % Test,
"org.scalatestplus" %% "scalatestplus-scalacheck" % scalatestplusScalaCheckVersion % Test,
"org.typelevel" %% "discipline-scalatest" % disciplineVersion % Test,
"org.scalatestplus" %% "scalatestplus-scalacheck" % scalatestPlusScalaCheckVersion % Test,
"org.typelevel" %% "discipline-scalatest" % disciplineScalatestVersion % Test,
"org.typelevel" %% "cats-laws" % catsVersion % Test
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import cats.implicits._
import com.typesafe.config.{ Config, ConfigFactory }
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.{ BeforeAndAfterAll, Matchers }
import org.scalatest.BeforeAndAfterAll
import org.scalatest.matchers.should.Matchers

import scala.concurrent.duration._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import org.scalacheck.Arbitrary._
import org.scalacheck.Prop.forAll
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import scodec.bits.BitVector

import scala.concurrent.Await
import scala.concurrent.duration._

class MessageSerializerTest extends AnyFunSuite with BeforeAndAfterAll with Checkers {
class MessageSerializerTest extends AnyFunSuite with BeforeAndAfterAll {

implicit val system: ActorSystem = ActorSystem("test")
val serialization = SerializationExtension(system)
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala/aecor/MonadAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ trait MonadActionReject[F[_], S, E, R] extends MonadAction[F, S, E] {
object MonadActionReject {
implicit def eitherTMonadActionRejectInstance[I[_]: Applicative, S, E, R](
implicit F: MonadAction[I, S, E],
eitherTMonad: Monad[EitherT[I, R, ?]]
): MonadActionReject[EitherT[I, R, ?], S, E, R] =
new MonadActionReject[EitherT[I, R, ?], S, E, R] {
eitherTMonad: Monad[EitherT[I, R, *]]
): MonadActionReject[EitherT[I, R, *], S, E, R] =
new MonadActionReject[EitherT[I, R, *], S, E, R] {
override def reject[A](r: R): EitherT[I, R, A] = EitherT.leftT(r)
override def read: EitherT[I, R, S] = EitherT.right(F.read)
override def append(es: E, other: E*): EitherT[I, R, Unit] =
Expand All @@ -45,9 +45,9 @@ trait MonadActionLiftReject[I[_], F[_], S, E, R]
object MonadActionLiftReject {
implicit def eitherTMonadActionLiftRejectInstance[I[_], F[_], S, E, R](
implicit I: MonadActionLift[I, F, S, E],
eitherTMonad: Monad[EitherT[I, R, ?]]
): MonadActionLiftReject[EitherT[I, R, ?], F, S, E, R] =
new MonadActionLiftReject[EitherT[I, R, ?], F, S, E, R] {
eitherTMonad: Monad[EitherT[I, R, *]]
): MonadActionLiftReject[EitherT[I, R, *], F, S, E, R] =
new MonadActionLiftReject[EitherT[I, R, *], F, S, E, R] {
override def reject[A](r: R): EitherT[I, R, A] = EitherT.leftT(r)
override def liftF[A](fa: F[A]): EitherT[I, R, A] = EitherT.right(I.liftF(fa))
override def read: EitherT[I, R, S] = EitherT.right(I.read)
Expand Down
24 changes: 12 additions & 12 deletions modules/core/src/main/scala/aecor/data/ActionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,25 @@ trait ActionTFunctions {

def sampleK[F[_]: Monad, S, E1, Env, E2](
getEnv: F[Env]
)(update: (Env, E1) => E2)(extract: E2 => E1): ActionT[F, S, E1, ?] ~> ActionT[F, S, E2, ?] =
new (ActionT[F, S, E1, ?] ~> ActionT[F, S, E2, ?]) {
)(update: (Env, E1) => E2)(extract: E2 => E1): ActionT[F, S, E1, *] ~> ActionT[F, S, E2, *] =
new (ActionT[F, S, E1, *] ~> ActionT[F, S, E2, *]) {
override def apply[A](fa: ActionT[F, S, E1, A]): ActionT[F, S, E2, A] =
fa.sample(getEnv)(update)(extract)
}

def xmapEventsK[F[_]: Functor, S, E1, E2, R](
to: E1 => E2,
from: E2 => E1
): ActionT[F, S, E1, ?] ~> ActionT[F, S, E2, ?] =
new (ActionT[F, S, E1, ?] ~> ActionT[F, S, E2, ?]) {
): ActionT[F, S, E1, *] ~> ActionT[F, S, E2, *] =
new (ActionT[F, S, E1, *] ~> ActionT[F, S, E2, *]) {
override def apply[A](fa: ActionT[F, S, E1, A]): ActionT[F, S, E2, A] =
fa.xmapEvents(to, from)
}

def expandK[F[_]: Functor, S1, S2, E](
update: (S2, S1) => S2
)(extract: S2 => S1): ActionT[F, S1, E, ?] ~> ActionT[F, S2, E, ?] =
new (ActionT[F, S1, E, ?] ~> ActionT[F, S2, E, ?]) {
)(extract: S2 => S1): ActionT[F, S1, E, *] ~> ActionT[F, S2, E, *] =
new (ActionT[F, S1, E, *] ~> ActionT[F, S2, E, *]) {
override def apply[A](fa: ActionT[F, S1, E, A]): ActionT[F, S2, E, A] =
fa.expand(update)(extract)
}
Expand All @@ -110,22 +110,22 @@ trait ActionTFunctions {
trait ActionTInstances extends ActionTLowerPriorityInstances1 {
implicit def monadActionLiftRejectInstance[F[_], S, E, R](
implicit F0: MonadError[F, R]
): MonadActionLiftReject[ActionT[F, S, E, ?], F, S, E, R] =
new MonadActionLiftReject[ActionT[F, S, E, ?], F, S, E, R]
): MonadActionLiftReject[ActionT[F, S, E, *], F, S, E, R] =
new MonadActionLiftReject[ActionT[F, S, E, *], F, S, E, R]
with ActionTMonadActionLiftInstance[F, S, E] {
override protected implicit def F: Monad[F] = F0
override def reject[A](r: R): ActionT[F, S, E, A] = ActionT.liftF(F0.raiseError[A](r))
}

implicit def actionTFunctorKInstance[S, E, A]: FunctorK[ActionT[?[_], S, E, A]] =
new FunctorK[ActionT[?[_], S, E, A]] {
implicit def actionTFunctorKInstance[S, E, A]: FunctorK[ActionT[*[_], S, E, A]] =
new FunctorK[ActionT[*[_], S, E, A]] {
def mapK[F[_], G[_]](a: ActionT[F, S, E, A])(f: ~>[F, G]): ActionT[G, S, E, A] = a.mapK(f)
}
}

trait ActionTLowerPriorityInstances1 {
trait ActionTMonadActionLiftInstance[F[_], S, E]
extends MonadActionLift[ActionT[F, S, E, ?], F, S, E] {
extends MonadActionLift[ActionT[F, S, E, *], F, S, E] {
protected implicit def F: Monad[F]
override def read: ActionT[F, S, E, S] = ActionT.read
override def append(e: E, es: E*): ActionT[F, S, E, Unit] =
Expand Down Expand Up @@ -166,7 +166,7 @@ trait ActionTLowerPriorityInstances1 {

implicit def monadActionLiftInstance[F[_], S, E](
implicit F0: Monad[F]
): MonadActionLift[ActionT[F, S, E, ?], F, S, E] =
): MonadActionLift[ActionT[F, S, E, *], F, S, E] =
new ActionTMonadActionLiftInstance[F, S, E] {
override protected implicit def F: Monad[F] = F0
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/aecor/data/Committable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ object Committable {
B.contramap(_.value)

implicit def catsMonadAndTraversInstance[F[_]: Applicative]
: Monad[Committable[F, ?]] with Traverse[Committable[F, ?]] =
new Monad[Committable[F, ?]] with Traverse[Committable[F, ?]] {
: Monad[Committable[F, *]] with Traverse[Committable[F, *]] =
new Monad[Committable[F, *]] with Traverse[Committable[F, *]] {
override def traverse[G[_], A, B](
fa: Committable[F, A]
)(f: (A) => G[B])(implicit evidence$1: Applicative[G]): G[Committable[F, B]] =
Expand Down
22 changes: 11 additions & 11 deletions modules/core/src/main/scala/aecor/data/EitherK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import cats.tagless.syntax.functorK._
/**
* Higher-kinded transformer for EitherT
*/
final case class EitherK[M[_[_]], A, F[_]](value: M[EitherT[F, A, ?]]) extends AnyVal {
final case class EitherK[M[_[_]], A, F[_]](value: M[EitherT[F, A, *]]) extends AnyVal {
def unwrap(implicit M: FunctorK[M]): M[λ[α => F[Either[A, α]]]] =
value.mapK(new (EitherT[F, A, ?] ~> λ[α => F[Either[A, α]]]) {
value.mapK(new (EitherT[F, A, *] ~> λ[α => F[Either[A, α]]]) {
override def apply[X](fa: EitherT[F, A, X]): F[Either[A, X]] = fa.value
})

def mapK[G[_]](fg: F ~> G)(implicit M: FunctorK[M]): EitherK[M, A, G] =
EitherK(M.mapK(value)(new (EitherT[F, A, ?] ~> EitherT[G, A, ?]) {
EitherK(M.mapK(value)(new (EitherT[F, A, *] ~> EitherT[G, A, *]) {
override def apply[X](fa: EitherT[F, A, X]): EitherT[G, A, X] =
fa.mapK(fg)
}))
Expand All @@ -30,12 +30,12 @@ object EitherK {
implicit def wireProtocol[M[_[_]]: FunctorK, A](
implicit M: WireProtocol[M],
aCodec: Codec[A]
): WireProtocol[EitherK[M, A, ?[_]]] =
new WireProtocol[EitherK[M, A, ?[_]]] {
): WireProtocol[EitherK[M, A, *[_]]] =
new WireProtocol[EitherK[M, A, *[_]]] {

final override val encoder: EitherK[M, A, Encoded] =
EitherK[M, A, Encoded] {
M.encoder.mapK(new (Encoded ~> EitherT[Encoded, A, ?]) {
M.encoder.mapK(new (Encoded ~> EitherT[Encoded, A, *]) {
override def apply[B](ma: Encoded[B]): EitherT[Encoded, A, B] =
EitherT[Encoded, A, B] {
val (bytes, resultDecoder) = ma
Expand All @@ -48,12 +48,12 @@ object EitherK {
})
}

final override val decoder: Decoder[PairE[Invocation[EitherK[M, A, ?[_]], ?], Encoder]] =
final override val decoder: Decoder[PairE[Invocation[EitherK[M, A, *[_]], *], Encoder]] =
M.decoder.map { p =>
val (invocation, encoder) = (p.first, p.second)

val eitherKInvocation =
new Invocation[EitherK[M, A, ?[_]], Either[A, p.A]] {
new Invocation[EitherK[M, A, *[_]], Either[A, p.A]] {
override def run[G[_]](target: EitherK[M, A, G]): G[Either[A, p.A]] =
invocation.run(target.value).value
override def toString: String = invocation.toString
Expand All @@ -72,14 +72,14 @@ object EitherK {
}
}

implicit def functorK[M[_[_]]: FunctorK, A]: FunctorK[EitherK[M, A, ?[_]]] =
new FunctorK[EitherK[M, A, ?[_]]] {
implicit def functorK[M[_[_]]: FunctorK, A]: FunctorK[EitherK[M, A, *[_]]] =
new FunctorK[EitherK[M, A, *[_]]] {
override def mapK[F[_], G[_]](af: EitherK[M, A, F])(fk: ~>[F, G]): EitherK[M, A, G] =
af.mapK(fk)
}

object syntax {
implicit final class EitherKSyntaxImpl[M[_[_]], F[_], A](val self: M[EitherT[F, A, ?]])
implicit final class EitherKSyntaxImpl[M[_[_]], F[_], A](val self: M[EitherT[F, A, *]])
extends AnyVal {
def toEitherK: EitherK[M, A, F] = EitherK(self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cats.data.{ Chain, EitherT }
import cats.tagless.FunctorK
import cats.tagless.syntax.functorK._

final case class EventsourcedBehavior[M[_[_]], F[_], S, E](actions: M[ActionT[F, S, E, ?]],
final case class EventsourcedBehavior[M[_[_]], F[_], S, E](actions: M[ActionT[F, S, E, *]],
fold: Fold[Folded, S, E]) {
def enrich[Env](f: F[Env])(implicit M: FunctorK[M],
F: Monad[F]): EventsourcedBehavior[M, F, S, Enriched[Env, E]] =
Expand All @@ -17,7 +17,7 @@ final case class EventsourcedBehavior[M[_[_]], F[_], S, E](actions: M[ActionT[F,
)

def mapK[G[_]](fg: F ~> G)(implicit M: FunctorK[M]): EventsourcedBehavior[M, G, S, E] =
copy(actions.mapK(λ[ActionT[F, S, E, ?] ~> ActionT[G, S, E, ?]](_.mapK(fg))))
copy(actions.mapK(λ[ActionT[F, S, E, *] ~> ActionT[G, S, E, *]](_.mapK(fg))))

def run[A](state: S, invocation: Invocation[M, A]): F[Folded[(Chain[E], A)]] =
invocation
Expand All @@ -27,16 +27,16 @@ final case class EventsourcedBehavior[M[_[_]], F[_], S, E](actions: M[ActionT[F,

object EventsourcedBehavior extends EventsourcedBehaviourIntances {
def rejectable[M[_[_]], F[_], S, E, R](
actions: M[EitherT[ActionT[F, S, E, ?], R, ?]],
actions: M[EitherT[ActionT[F, S, E, *], R, *]],
fold: Fold[Folded, S, E]
): EventsourcedBehavior[EitherK[M, R, ?[_]], F, S, E] =
EventsourcedBehavior[EitherK[M, R, ?[_]], F, S, E](EitherK(actions), fold)
): EventsourcedBehavior[EitherK[M, R, *[_]], F, S, E] =
EventsourcedBehavior[EitherK[M, R, *[_]], F, S, E](EitherK(actions), fold)
}

trait EventsourcedBehaviourIntances {
implicit def eventsourcedBehaviourFunctorKInstance[M[_[_]]: FunctorK, S, E]
: FunctorK[EventsourcedBehavior[M, ?[_], S, E]] =
new FunctorK[EventsourcedBehavior[M, ?[_], S, E]] {
: FunctorK[EventsourcedBehavior[M, *[_], S, E]] =
new FunctorK[EventsourcedBehavior[M, *[_], S, E]] {
def mapK[F[_], G[_]](a: EventsourcedBehavior[M, F, S, E])(
f: F ~> G
): EventsourcedBehavior[M, G, S, E] = a.mapK(f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scodec.bits.BitVector
import scodec.{ Decoder, Encoder }

trait WireProtocol[M[_[_]]] {
def decoder: Decoder[PairE[Invocation[M, ?], Encoder]]
def decoder: Decoder[PairE[Invocation[M, *], Encoder]]
def encoder: M[WireProtocol.Encoded]
}

Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/aecor/runtime/Eventsourced.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Eventsourced {

{ key =>
Ref[F].of(none[Versioned[S]]).map { cache =>
behavior.actions.mapK(Lambda[ActionT[F, S, E, ?] ~> F] { action =>
behavior.actions.mapK(Lambda[ActionT[F, S, E, *] ~> F] { action =>
for {
before <- cache.get.flatMap {
case Some(before) => before.pure[F]
Expand Down Expand Up @@ -57,7 +57,7 @@ object Eventsourced {

{ key =>
behavior.actions.mapK {
Lambda[ActionT[G, S, E, ?] ~> F] { action =>
Lambda[ActionT[G, S, E, *] ~> F] { action =>
for {
snapshot <- snapshotting.load(key)
(before, (after, a)) <- journalBoundary {
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala/aecor/runtime/KeyValueStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ trait KeyValueStore[F[_], K, A] { self =>
}

object KeyValueStore {
implicit def catsTaglessFunctorKInstance[K, A]: FunctorK[KeyValueStore[?[_], K, A]] =
new FunctorK[KeyValueStore[?[_], K, A]] {
implicit def catsTaglessFunctorKInstance[K, A]: FunctorK[KeyValueStore[*[_], K, A]] =
new FunctorK[KeyValueStore[*[_], K, A]] {
override def mapK[F[_], G[_]](
mf: KeyValueStore[F, K, A]
)(fg: F ~> G): KeyValueStore[G, K, A] =
mf.mapK(fg)
}

implicit def catsInvariantInstance[F[_]: Functor, K]: Invariant[KeyValueStore[F, K, ?]] =
new Invariant[KeyValueStore[F, K, ?]] {
implicit def catsInvariantInstance[F[_]: Functor, K]: Invariant[KeyValueStore[F, K, *]] =
new Invariant[KeyValueStore[F, K, *]] {
override def imap[A, B](
fa: KeyValueStore[F, K, A]
)(f: A => B)(g: B => A): KeyValueStore[F, K, B] =
fa.imap(f)(g)
}

implicit def catsContravarianFunctor[F[_], A]: Contravariant[KeyValueStore[F, ?, A]] =
new Contravariant[KeyValueStore[F, ?, A]] {
implicit def catsContravarianFunctor[F[_], A]: Contravariant[KeyValueStore[F, *, A]] =
new Contravariant[KeyValueStore[F, *, A]] {
override def contramap[K1, K2](
fa: KeyValueStore[F, K1, A]
)(f: K2 => K1): KeyValueStore[F, K2, A] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class EventsourcedAlgebra[F[_]](
}

object EventsourcedAlgebra {
def behavior[F[_]: Monad]: EventsourcedBehavior[EitherK[Algebra, Rejection, ?[_]], F, Option[
def behavior[F[_]: Monad]: EventsourcedBehavior[EitherK[Algebra, Rejection, *[_]], F, Option[
AccountState
], AccountEvent] =
EventsourcedBehavior
Expand Down
Loading

0 comments on commit 59bd183

Please sign in to comment.