Skip to content
Permalink
Browse files

Updated dependencies and removed deprecation warnings

  • Loading branch information
kiroco12 committed Nov 15, 2019
1 parent 575e192 commit b535ce746cf2b40423146c3adcd88abc6a2e6c42
Showing with 151 additions and 141 deletions.
  1. +10 −8 build.sbt
  2. +21 −12 project/ProjectPlugin.scala
  3. +1 −1 project/build.properties
  4. +2 −2 project/plugins.sbt
  5. +3 −2 src/main/scala/catslib/Applicative.scala
  6. +7 −6 src/main/scala/catslib/Apply.scala
  7. +3 −2 src/main/scala/catslib/ApplyHelpers.scala
  8. +3 −2 src/main/scala/catslib/CatsLibrary.scala
  9. +3 −2 src/main/scala/catslib/EitherSection.scala
  10. +3 −2 src/main/scala/catslib/Foldable.scala
  11. +3 −2 src/main/scala/catslib/FunctorSection.scala
  12. +3 −2 src/main/scala/catslib/IdentitySection.scala
  13. +4 −4 src/main/scala/catslib/Monad.scala
  14. +4 −3 src/main/scala/catslib/MonadHelpers.scala
  15. +3 −2 src/main/scala/catslib/Monoid.scala
  16. +4 −6 src/main/scala/catslib/Semigroup.scala
  17. +7 −18 src/main/scala/catslib/Traverse.scala
  18. +3 −2 src/main/scala/catslib/TraverseHelpers.scala
  19. +4 −8 src/main/scala/catslib/Validated.scala
  20. +4 −10 src/main/scala/catslib/ValidatedHelpers.scala
  21. +5 −4 src/test/scala/catslib/ApplicativeSpec.scala
  22. +5 −4 src/test/scala/catslib/ApplySpec.scala
  23. +5 −4 src/test/scala/catslib/EitherSpec.scala
  24. +5 −4 src/test/scala/catslib/FoldableSpec.scala
  25. +5 −4 src/test/scala/catslib/FunctorSpec.scala
  26. +5 −4 src/test/scala/catslib/IdentitySpec.scala
  27. +5 −4 src/test/scala/catslib/MonadSpec.scala
  28. +5 −4 src/test/scala/catslib/MonoidSpec.scala
  29. +5 −4 src/test/scala/catslib/SemigroupSpec.scala
  30. +5 −4 src/test/scala/catslib/TraverseSpec.scala
  31. +5 −4 src/test/scala/catslib/ValidatedSpec.scala
  32. +1 −1 version.sbt
@@ -1,21 +1,23 @@
val scalaExercisesV = "0.4.0-SNAPSHOT"
import ProjectPlugin.autoImport._
val scalaExercisesV = "0.5.0-SNAPSHOT"

def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExercisesV

lazy val cats = (project in file("."))
.enablePlugins(ExerciseCompilerPlugin)
.disablePlugins(CoursierPlugin)
//.disablePlugins(CoursierPlugin)
.settings(
name := "exercises-cats",
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("cats"),
%%("shapeless"),
%%("scalatest"),
%%("scalacheck"),
%%("scheckShapeless")
)
%%("cats-core", V.cats),
%%("shapeless", V.shapeless),
%%("scalatest", V.scalatest),
%%("scalacheck", V.scalacheck),
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % V.scalacheckShapeless
),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full)
)

// Distribution
@@ -1,4 +1,4 @@
import de.heikoseeberger.sbtheader.HeaderPattern
import de.heikoseeberger.sbtheader.License._
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import sbt.Keys._
import sbt._
@@ -12,6 +12,20 @@ object ProjectPlugin extends AutoPlugin {

override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin

object autoImport {

lazy val V = new {
val scala212: String = "2.12.10"
val cats: String = "2.0.0"
val shapeless: String = "2.3.3"
val scalatest: String = "3.0.8"
val scalacheck: String = "1.14.2"
val scalacheckShapeless: String = "1.2.3"
}
}

import autoImport._

override def projectSettings: Seq[Def.Setting[_]] =
Seq(
description := "Scala Exercises: The path to enlightenment",
@@ -25,22 +39,17 @@ object ProjectPlugin extends AutoPlugin {
organizationEmail = "hello@47deg.com"
),
orgLicenseSetting := ApacheLicense,
scalaVersion := "2.11.11",
scalaVersion := V.scala212,
scalaOrganization := "org.scala-lang",
crossScalaVersions := Seq("2.11.11"),
resolvers ++= Seq(
Resolver.mavenLocal,
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
headers := Map(
"scala" -> (HeaderPattern.cStyleBlockComment,
s"""|/*
| * scala-exercises - ${name.value}
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
| */
|
|""".stripMargin)
)
scalacOptions += "-Ypartial-unification",
headerLicense := Some(Custom(s"""| scala-exercises - ${name.value}
| Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
|
|""".stripMargin))
)
}
@@ -1 +1 @@
sbt.version=0.13.15
sbt.version=1.2.8
@@ -2,5 +2,5 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)

addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.5.13")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.5.0-SNAPSHOT")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3")
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -147,11 +148,11 @@ object ApplySection extends FlatSpec with Matchers with org.scalaexercises.defin
res5: Option[(Int, Int, Int)]
) = {
import cats.implicits._
val option2 = Option(1) |@| Option(2)
val option3 = option2 |@| Option.empty[Int]
val option2 = (Option(1), Option(2))
val option3 = (option2._1, option2._2, Option.empty[Int])

option2 map addArity2 should be(res0)
option3 map addArity3 should be(res1)
option2 mapN addArity2 should be(res0)
option3 mapN addArity3 should be(res1)

option2 apWith Some(addArity2) should be(res2)
option3 apWith Some(addArity3) should be(res3)
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,13 +1,13 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib

import org.scalatest._

import cats._
import MonadHelpers._

/** `Monad` extends the `Applicative` type class with a
@@ -114,7 +114,7 @@ object MonadSection extends FlatSpec with Matchers with org.scalaexercises.defin
* case class OptionT[F[_], A](value: F[Option[A]])
* implicit def optionTMonad[F[_]](implicit F : Monad[F]) = {
* new Monad[OptionT[F, ?]] {
* new Monad[OptionT[F, *]] {
* def pure[A](a: A): OptionT[F, A] = OptionT(F.pure(Some(a)))
* def flatMap[A, B](fa: OptionT[F, A])(f: A => OptionT[F, B]): OptionT[F, B] =
* OptionT {
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -12,7 +13,7 @@ object MonadHelpers {
case class OptionT[F[_], A](value: F[Option[A]])

implicit def optionTMonad[F[_]](implicit F: Monad[F]) = {
new Monad[OptionT[F, ?]] {
new Monad[OptionT[F, *]] {
def pure[A](a: A): OptionT[F, A] = OptionT(F.pure(Some(a)))
def flatMap[A, B](fa: OptionT[F, A])(f: A OptionT[F, B]): OptionT[F, B] =
OptionT {
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -35,10 +36,7 @@ import org.scalatest._
*
* @param name semigroup
*/
object SemigroupSection
extends FlatSpec
with Matchers
with org.scalaexercises.definitions.Section {
object SemigroupSection extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {

/** Now that you've learned about the `Semigroup` instance for `Int` try to
* guess how it works in the following examples:
@@ -1,13 +1,13 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib

import org.scalatest._

import cats.data.ValidatedNel
import cats.implicits._

import TraverseHelpers._
@@ -92,13 +92,6 @@ object TraverseSection extends FlatSpec with Matchers with org.scalaexercises.de
* walks the `F[A]` depends on the effect of the function. Let's see some examples where `F` is taken to be
* `List`.
*
* Note in the following code snippet we are using `traverseU` instead of `traverse`.
* `traverseU` is for all intents and purposes the same as `traverse`, but with some
* [[http://typelevel.org/blog/2013/09/11/using-scalaz-Unapply.html type-level trickery]]
* to allow it to infer the `Applicative[Either[A, ?]]` and `Applicative[Validated[A, ?]]`
* instances - `scalac` has issues inferring the instances for data types that do not
* trivially satisfy the `F[_]` shape required by `Applicative`.
*
* {{{
* import cats.Semigroup
* import cats.data.{NonEmptyList, OneAnd, Validated, ValidatedNel}
@@ -115,8 +108,8 @@ object TraverseSection extends FlatSpec with Matchers with org.scalaexercises.de
* and accumulating failures with `Either`.
*/
def traverseuFunction(res0: List[Int], res1: Boolean) = {
List("1", "2", "3").traverseU(parseIntEither) should be(Right(res0))
List("1", "abc", "3").traverseU(parseIntEither).isLeft should be(res1)
List("1", "2", "3").traverse(parseIntEither) should be(Right(res0))
List("1", "abc", "3").traverse(parseIntEither).isLeft should be(res1)
}

/** We need proof that `NonEmptyList[A]` is a `Semigroup `for there to be an `Applicative` instance for
@@ -129,12 +122,8 @@ object TraverseSection extends FlatSpec with Matchers with org.scalaexercises.de
*
* Now that we've provided such evidence, we can use `ValidatedNel` as an applicative.
*/
def traverseuValidated(res0: Boolean) = {
import cats.Semigroup
import cats.data.{NonEmptyList, OneAnd, ValidatedNel}

List("1", "2", "3").traverseU(parseIntValidated).isValid should be(res0)
}
def traverseuValidated(res0: Boolean) =
List("1", "2", "3").traverse(parseIntValidated).isValid should be(res0)

/** Notice that in the `Either` case, should any string fail to parse the entire traversal
* is considered a failure. Moreover, once it hits its first bad parse, it will not
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-cats
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-cats
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package catslib
@@ -165,10 +166,7 @@ import ValidatedHelpers._
*
* @param name validated
*/
object ValidatedSection
extends FlatSpec
with Matchers
with org.scalaexercises.definitions.Section {
object ValidatedSection extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {

/** When no errors are present in the configuration, we get a `ConnectionParams` wrapped in a `Valid` instance.
*/
@@ -358,8 +356,6 @@ object ValidatedSection
*
*/
def validatedAsEither(res0: Boolean, res1: Boolean) = {
import cats.implicits._

val config = Config(Map("house_number" "-42"))

val houseNumber = config.parse[Int]("house_number").withEither {

0 comments on commit b535ce7

Please sign in to comment.
You can’t perform that action at this time.