Skip to content

Update to Scala 2.13.1 #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version=2.3.2
style = defaultWithAlign
maxColumn = 100

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: scala
scala:
- 2.11.11
- 2.13.1
jdk:
- openjdk8
script:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ProjectPlugin.autoImport._

val scalaExercisesV = "0.5.0-SNAPSHOT"
val scalaExercisesV = "0.6.0-SNAPSHOT"

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

Expand Down
6 changes: 3 additions & 3 deletions project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ object ProjectPlugin extends AutoPlugin {
object autoImport {

lazy val V = new {
val scala212: String = "2.12.10"
val scala213: String = "2.13.1"
val shapeless: String = "2.3.3"
val scalatest: String = "3.1.0"
val scalatestplusScheck: String = "3.1.0.0-RC2"
val scalacheck: String = "1.14.2"
val scalacheck: String = "1.14.3"
val scalacheckShapeless: String = "1.2.3"
}
}
Expand All @@ -39,7 +39,7 @@ object ProjectPlugin extends AutoPlugin {
organizationEmail = "[email protected]"
),
orgLicenseSetting := ApacheLicense,
scalaVersion := V.scala212,
scalaVersion := V.scala213,
scalaOrganization := "org.scala-lang",
resolvers ++= Seq(
Resolver.mavenLocal,
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.8
sbt.version=1.3.7
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)

addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.5.0-SNAPSHOT")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.0-SNAPSHOT")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3")
5 changes: 3 additions & 2 deletions src/main/scala/shapeless/ArityExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import ops.function._
import syntax.std.function._

object Helper {
def applyProduct[P <: Product, F, L <: HList, R](p: P)(
f: F)(implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L ⇒ R]) =
def applyProduct[P <: Product, F, L <: HList, R](
p: P
)(f: F)(implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L => R]) =
f.toProduct(gen.to(p))
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/shapeless/AutoTypeClassExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object Monoid extends ProductTypeClassCompanion[Monoid] {
def append(a: F :: T, b: F :: T) = mh.append(a.head, b.head) :: mt.append(a.tail, b.tail)
}

def project[F, G](instance: Monoid[G], to: F G, from: G F) = new Monoid[F] {
def project[F, G](instance: => Monoid[G], to: F => G, from: G => F) = new Monoid[F] {
def zero = from(instance.zero)
def append(a: F, b: F) = from(instance.append(to(a), to(b)))
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/scala/shapeless/CoproductExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ object CoproductExercises
type ISB = Int :+: String :+: Boolean :+: CNil

object sizeM extends Poly1 {
implicit def caseInt = at[Int](i (i, i))
implicit def caseString = at[String](s (s, s.length))
implicit def caseBoolean = at[Boolean](b (b, 1))
implicit def caseInt = at[Int](i => (i, i))
implicit def caseString = at[String](s => (s, s.length))
implicit def caseBoolean = at[Boolean](b => (b, 1))
}

val isb = Coproduct[ISB]("foo")
Expand Down Expand Up @@ -72,11 +72,11 @@ object CoproductExercises

type U = Union.`'i -> Int, 's -> String, 'b -> Boolean`.T

val u = Coproduct[U]('s ->> "foo") // Inject a String into the union at label 's
val u = Coproduct[U](Symbol("s") ->> "foo") // Inject a String into the union at label 's

u.get('i) should be(res0)
u.get('s) should be(res1)
u.get('b) should be(res2)
u.get(Symbol("i")) should be(res0)
u.get(Symbol("s")) should be(res1)
u.get(Symbol("b")) should be(res2)
}

}
14 changes: 6 additions & 8 deletions src/main/scala/shapeless/GenericExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object GenericHelper {
// Polymorphic function which adds 1 to any Int and is the identity
// on all other values
// format: OFF
object inc extends -> ((i: Int) i + 1)
object inc extends -> ((i: Int) => i + 1)
// format: ON
case class Book(author: String, title: String, id: Int, price: Double)
case class ExtendedBook(author: String, title: String, id: Int, price: Double, inPrint: Boolean)
Expand Down Expand Up @@ -124,21 +124,19 @@ object GenericExercises
val tapl = Book("Benjamin Pierce", "Types and Programming Languages", 262162091, 44.11)
val rec = bookGen.to(tapl)

rec('price) should be(res0)
rec(Symbol("price")) should be(res0)

val updatedBook = bookGen.from(rec.updateWith('price)(_ + 2.0))
val updatedBook = bookGen.from(rec.updateWith(Symbol("price"))(_ + 2.0))

updatedBook.price should be(res1)

/** {{{
* case class ExtendedBook(author: String, title: String, id: Int, price: Double, inPrint: Boolean)
* }}}
*/
// case class ExtendedBook(author: String, title: String, id: Int, price: Double, inPrint: Boolean)

import syntax.singleton._

val bookExtGen = LabelledGeneric[ExtendedBook]

val extendedBook = bookExtGen.from(rec + ('inPrint ->> true))
val extendedBook = bookExtGen.from(rec + (Symbol("inPrint") ->> true))

extendedBook.inPrint should be(res2)
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/shapeless/HListExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import org.scalatest.matchers.should.Matchers
import shapeless._

object size extends Poly1 {
implicit def caseInt = at[Int](x 1)
implicit def caseInt = at[Int](x => 1)
implicit def caseString = at[String](_.length)
implicit def caseTuple[T, U](implicit st: Case.Aux[T, Int], su: Case.Aux[U, Int]) =
at[(T, U)](t size(t._1) + size(t._2))
at[(T, U)](t => size(t._1) + size(t._2))
}

object addSize extends Poly2 {
implicit def default[T](implicit st: shapelessex.size.Case.Aux[T, Int]) =
at[Int, T] { (acc, t)
at[Int, T] { (acc, t) =>
acc + size(t)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/shapeless/HMapExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object HMapExercises extends AnyFlatSpec with Matchers with org.scalaexercises.d
implicit val intToString = new BiMapIS[Int, String]
implicit val stringToInt = new BiMapIS[String, Int]

val hm = HMap[BiMapIS](23 "foo", "bar" 13)
val hm = HMap[BiMapIS](23 -> "foo", "bar" -> 13)
//val hm2 = HMap[BiMapIS](23 -> "foo", 23 -> 13) // Does not compile
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/shapeless/LazyExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ object LazyExercises extends AnyFlatSpec with Matchers with org.scalaexercises.d
implicit def showList[T](implicit sc: Lazy[Show[Cons[T]]]): Show[List[T]] =
new Show[List[T]] {
def apply(t: List[T]) = t match {
case n: Nil show(n)
case c: Cons[T] show(c)(sc.value)
case n: Nil => show(n)
case c: Cons[T] => show(c)(sc.value)
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/scala/shapeless/LensesExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import shapeless._
* case class Person(name : String, age : Int, address : Address)
*
* // Some lenses over Person/Address ...
* val nameLens = lens[Person] >> 'name
* val ageLens = lens[Person] >> 'age
* val addressLens = lens[Person] >> 'address
* val streetLens = lens[Person] >> 'address >> 'street
* val cityLens = lens[Person] >> 'address >> 'city
* val postcodeLens = lens[Person] >> 'address >> 'postcode
* val nameLens = lens[Person] >> Symbol("name")
* val ageLens = lens[Person] >> Symbol("age")
* val addressLens = lens[Person] >> Symbol("address")
* val streetLens = lens[Person] >> Symbol("address") >> Symbol("street")
* val cityLens = lens[Person] >> Symbol("address") >> Symbol("city")
* val postcodeLens = lens[Person] >> Symbol("address") >> Symbol("postcode")
*
* val person = Person("Joe Grey", 37, Address("Southover Street", "Brighton", "BN2 9UA"))
* }}}
Expand All @@ -44,12 +44,12 @@ object LensesExercises
case class Person(name: String, age: Int, address: Address)

// Some lenses over Person/Address ...
val nameLens = lens[Person] >> 'name
val ageLens = lens[Person] >> 'age
val addressLens = lens[Person] >> 'address
val streetLens = lens[Person] >> 'address >> 'street
val cityLens = lens[Person] >> 'address >> 'city
val postcodeLens = lens[Person] >> 'address >> 'postcode
val nameLens = lens[Person] >> Symbol("name")
val ageLens = lens[Person] >> Symbol("age")
val addressLens = lens[Person] >> Symbol("address")
val streetLens = lens[Person] >> Symbol("address") >> Symbol("street")
val cityLens = lens[Person] >> Symbol("address") >> Symbol("city")
val postcodeLens = lens[Person] >> Symbol("address") >> Symbol("postcode")

val person = Person("Joe Grey", 37, Address("Southover Street", "Brighton", "BN2 9UA"))
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/shapeless/PolyExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ object PolyExercises extends AnyFlatSpec with Matchers with org.scalaexercises.d
def exerciseSize(res0: Int, res1: Int, res2: Int, res3: Int) = {

object size extends Poly1 {
implicit def caseInt = at[Int](x 1)
implicit def caseInt = at[Int](x => 1)
implicit def caseString = at[String](_.length)
implicit def caseTuple[T, U](implicit st: Case.Aux[T, Int], su: Case.Aux[U, Int]) =
at[(T, U)](t size(t._1) + size(t._2))
at[(T, U)](t => size(t._1) + size(t._2))
}

size(23) should be(res0)
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/shapeless/TuplesHListExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ object TuplesHListExercises
}

object sizeOf extends Poly1 {
implicit def caseInt = at[Int](x 1)
implicit def caseInt = at[Int](x => 1)
implicit def caseString = at[String](_.length)
implicit def caseTuple[T, U](implicit st: Case.Aux[T, Int], su: Case.Aux[U, Int]) =
at[(T, U)](t sizeOf(t._1) + sizeOf(t._2))
at[(T, U)](t => sizeOf(t._1) + sizeOf(t._2))
}

object addSize extends Poly2 {
implicit def default[T](implicit st: sizeOf.Case.Aux[T, Int]) =
at[Int, T] { (acc, t)
at[Int, T] { (acc, t) =>
acc + sizeOf(t)
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/shapeless/TypeSafeCastExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ object TypeSafeCastExercises
def typesafeCast(
res0: Option[List[Vector[String]]],
res1: Option[List[Vector[Int]]],
res2: Option[List[List[String]]]) = {
res2: Option[List[List[String]]]
) = {
import syntax.typeable._

val l: Any = List(Vector("foo", "bar", "baz"), Vector("wibble"))
Expand All @@ -47,8 +48,8 @@ object TypeSafeCastExercises
val l = List(1, 2, 3)

val result = (l: Any) match {
case `List[String]`(List(s, _*)) s.length
case `List[Int]`(List(i, _*)) i + 1
case `List[String]`(List(s, _*)) => s.length
case `List[Int]`(List(i, _*)) => i + 1
}

result should be(res0)
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.5.0-SNAPSHOT"
version in ThisBuild := "0.6.0-SNAPSHOT"