diff --git a/.travis.yml b/.travis.yml index 571230d..7be987c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: required language: scala scala: - - 2.12.5 + - 2.12.8 jdk: - oraclejdk8 diff --git a/README.md b/README.md index 16e0ebb..42598c8 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ In case of complex algorithms, it's worthy to share codebase between platforms. // Bintray repo is used so far. Migration to Maven Central is planned resolvers += Resolver.bintrayRepo("fluencelabs", "releases") -val codecV = "0.0.1" +val codecV = "0.0.4" libraryDependencies ++= Seq( "one.fluence" %%% "codec-core" % codecV, // basic types diff --git a/build.sbt b/build.sbt index 931c2e9..df91c4c 100644 --- a/build.sbt +++ b/build.sbt @@ -10,11 +10,11 @@ javaOptions in Test ++= Seq("-ea") skip in publish := true // Skip root project -val scalaV = scalaVersion := "2.12.5" +val scalaV = scalaVersion := "2.12.8" val commons = Seq( scalaV, - version := "0.0.3", + version := "0.0.4", fork in Test := true, parallelExecution in Test := false, organization := "one.fluence", @@ -30,17 +30,17 @@ val commons = Seq( commons -val kindProjector = addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6") +val kindProjector = addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.9") -val Cats1V = "1.1.0" -val ScodecBitsV = "1.1.5" -val CirceV = "0.9.3" +val Cats1V = "1.5.0" +val ScodecBitsV = "1.1.9" +val CirceV = "0.11.1" val ShapelessV = "2.3.+" -val chill = "com.twitter" %% "chill" % "0.9.2" +val chill = "com.twitter" %% "chill" % "0.9.3" val ScalatestV = "3.0.+" -val ScalacheckV = "1.13.4" +val ScalacheckV = "1.14.+" val protobuf = Seq( PB.targets in Compile := Seq( @@ -64,7 +64,7 @@ lazy val `codec-core` = crossProject(JVMPlatform, JSPlatform) "org.typelevel" %%% "cats-core" % Cats1V, "org.typelevel" %%% "cats-laws" % Cats1V % Test, "org.typelevel" %%% "cats-testkit" % Cats1V % Test, - "com.github.alexarchambault" %%% "scalacheck-shapeless_1.13" % "1.1.8" % Test, + "com.github.alexarchambault" %%% "scalacheck-shapeless_1.14" % "1.2.0-1" % Test, "org.scalacheck" %%% "scalacheck" % ScalacheckV % Test, "org.scalatest" %%% "scalatest" % ScalatestV % Test ) diff --git a/core/src/main/scala/fluence/codec/Codec.scala b/core/src/main/scala/fluence/codec/Codec.scala deleted file mode 100644 index 04146e5..0000000 --- a/core/src/main/scala/fluence/codec/Codec.scala +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2017 Fluence Labs Limited - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package fluence.codec - -import cats.data.Kleisli -import cats.{Applicative, FlatMap, Traverse} -import cats.syntax.applicative._ - -import scala.language.{higherKinds, implicitConversions} - -/** - * Base trait for serialize/deserialize objects. - * - * @tparam A The type of plain object representation - * @tparam B The type of binary representation - * @tparam F Encoding/decoding effect - */ -@deprecated( - "Codec is planned for removing soon, as it's impure and not properly tested. Use PureCodec instead.", - "6.4.2018" -) -final case class Codec[F[_], A, B](encode: A ⇒ F[B], decode: B ⇒ F[A]) { - self ⇒ - - implicit val direct: Kleisli[F, A, B] = Kleisli(encode) - - implicit val inverse: Kleisli[F, B, A] = Kleisli(decode) - - def andThen[C](other: Codec[F, B, C])(implicit F: FlatMap[F]): Codec[F, A, C] = - Codec((self.direct andThen other.direct).run, (other.inverse andThen self.inverse).run) - - def compose[C](other: Codec[F, C, A])(implicit F: FlatMap[F]): Codec[F, C, B] = - Codec((other.direct andThen self.direct).run, (self.inverse andThen other.inverse).run) - - def swap: Codec[F, B, A] = Codec(decode, encode) -} - -@deprecated( - "Codec is planned for removing soon, as it's impure and not properly tested. Use PureCodec instead.", - "6.4.2018" -) -object Codec { - implicit def identityCodec[F[_]: Applicative, T]: Codec[F, T, T] = - Codec(_.pure[F], _.pure[F]) - - implicit def traverseCodec[F[_]: Applicative, G[_]: Traverse, O, B]( - implicit codec: Codec[F, O, B] - ): Codec[F, G[O], G[B]] = - Codec[F, G[O], G[B]](Traverse[G].traverse[F, O, B](_)(codec.encode), Traverse[G].traverse[F, B, O](_)(codec.decode)) - - implicit def toDirect[F[_], A, B](implicit cod: Codec[F, A, B]): Kleisli[F, A, B] = - cod.direct - - implicit def toInverse[F[_], A, B](implicit cod: Codec[F, A, B]): Kleisli[F, B, A] = - cod.inverse - - implicit def swap[F[_], A, B](implicit cod: Codec[F, A, B]): Codec[F, B, A] = - Codec[F, B, A](cod.decode, cod.encode) - - @deprecated( - "Codec is planned for removing soon, as it's impure and not properly tested. Use PureCodec instead.", - "6.4.2018" - ) - def codec[F[_], O, B](implicit codec: Codec[F, O, B]): Codec[F, O, B] = codec - - /** - * Constructs a Codec from pure encode/decode functions and an Applicative - * - * @param encodeFn Encode function that never fail - * @param decodeFn Decode function that never fail - * @tparam F Applicative effect - * @tparam O Raw type - * @tparam B Encoded type - * @return New codec for O and B - */ - @deprecated( - "Codec is planned for removing soon, as it's impure and not properly tested. Use PureCodec instead.", - "6.4.2018" - ) - def pure[F[_]: Applicative, O, B](encodeFn: O ⇒ B, decodeFn: B ⇒ O): Codec[F, O, B] = - Codec(encodeFn(_).pure[F], decodeFn(_).pure[F]) -} diff --git a/core/src/main/scala/fluence/codec/MonadicalEitherArrow.scala b/core/src/main/scala/fluence/codec/MonadicalEitherArrow.scala index 4c8cfc5..4ad45c6 100644 --- a/core/src/main/scala/fluence/codec/MonadicalEitherArrow.scala +++ b/core/src/main/scala/fluence/codec/MonadicalEitherArrow.scala @@ -121,13 +121,6 @@ abstract class MonadicalEitherArrow[E <: Throwable] { */ lazy val swap: Bijection[B, A] = Bijection(inverse, direct) - @deprecated( - "You should keep codec Pure until running direct or inverse on it: there's no reason to bind effect into Codec", - "6.4.2018" - ) - def toCodec[F[_]](implicit F: MonadError[F, Throwable]): Codec[F, A, B] = - Codec(direct.runF[F], inverse.runF[F]) - /** * Splits the input and puts it to either bijection, then merges output. * It could have been achieved with `Strong` typeclass in case it doesn't extend `Profunctor`; but it does. diff --git a/kryo/src/main/scala/fluence/codec/kryo/KryoCodecs.scala b/kryo/src/main/scala/fluence/codec/kryo/KryoCodecs.scala index 8f09977..42cd08a 100644 --- a/kryo/src/main/scala/fluence/codec/kryo/KryoCodecs.scala +++ b/kryo/src/main/scala/fluence/codec/kryo/KryoCodecs.scala @@ -19,12 +19,11 @@ package fluence.codec.kryo import cats.MonadError import com.twitter.chill.KryoPool -import fluence.codec.{Codec, CodecError, PureCodec} +import fluence.codec.{CodecError, PureCodec} import shapeless._ import scala.language.higherKinds import scala.reflect.ClassTag -import scala.util.Try import scala.util.control.NonFatal /** @@ -42,11 +41,8 @@ class KryoCodecs[F[_], L <: HList] private (pool: KryoPool)(implicit F: MonadErr * * @param sel Shows the presence of type T within list L * @tparam T Object type - * @return Freshly created Codec with Kryo inside + * @return Freshly created PureCodec with Kryo inside */ - implicit def codec[T](implicit sel: ops.hlist.Selector[L, T]): Codec[F, T, Array[Byte]] = - pureCodec[T].toCodec[F] - implicit def pureCodec[T](implicit sel: ops.hlist.Selector[L, T]): PureCodec[T, Array[Byte]] = PureCodec.Bijection( PureCodec.liftFuncEither { input ⇒ diff --git a/project/build.properties b/project/build.properties index 90e7013..dca663d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.1.4 +sbt.version = 1.2.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index 4759522..6a09260 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,21 +1,21 @@ -addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.4.0") +addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.15") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "4.1.0") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0") -addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18") +addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.19") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") -addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.3.1") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.26") +addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.6.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.10.0") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.13.1") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2") -addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.0") +addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.1") -libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.7.1" +libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.8.4" addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") \ No newline at end of file