Skip to content

Commit 8a66591

Browse files
authored
Merge pull request #48 from scala-exercises/enrique-2-12-10-update
Update to Scala 2.12.10
2 parents 491ce39 + 221b513 commit 8a66591

36 files changed

+258
-232
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: scala
22
scala:
3-
- 2.11.11
3+
- 2.12.10
44
jdk:
55
- openjdk8
66
script:

build.sbt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
val scalaExercisesV = "0.4.0-SNAPSHOT"
1+
import ProjectPlugin.autoImport._
2+
val scalaExercisesV = "0.5.0-SNAPSHOT"
23

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

@@ -9,9 +10,10 @@ lazy val fpinscala = (project in file("."))
910
libraryDependencies ++= Seq(
1011
dep("exercise-compiler"),
1112
dep("definitions"),
12-
%%("scalatest"),
13-
%%("scalacheck"),
14-
%%("scheckShapeless")
13+
%%("shapeless", V.shapeless),
14+
%%("scalatest", V.scalatest),
15+
%%("scalacheck", V.scalacheck),
16+
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % V.scalacheckShapeless
1517
)
1618
)
1719

project/ProjectPlugin.scala

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import de.heikoseeberger.sbtheader.HeaderPattern
1+
import de.heikoseeberger.sbtheader.License._
22
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
33
import sbt.Keys._
44
import sbt._
@@ -12,6 +12,19 @@ object ProjectPlugin extends AutoPlugin {
1212

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

15+
object autoImport {
16+
17+
lazy val V = new {
18+
val scala212: String = "2.12.10"
19+
val shapeless: String = "2.3.3"
20+
val scalatest: String = "3.0.8"
21+
val scalacheck: String = "1.14.2"
22+
val scalacheckShapeless: String = "1.2.3"
23+
}
24+
}
25+
26+
import autoImport._
27+
1528
override def projectSettings: Seq[Def.Setting[_]] =
1629
Seq(
1730
description := "Scala Exercises: The path to enlightenment",
@@ -25,23 +38,17 @@ object ProjectPlugin extends AutoPlugin {
2538
organizationEmail = "[email protected]"
2639
),
2740
orgLicenseSetting := ApacheLicense,
28-
scalaVersion := "2.11.11",
41+
scalaVersion := V.scala212,
2942
scalaOrganization := "org.scala-lang",
30-
crossScalaVersions := Seq("2.11.11"),
3143
resolvers ++= Seq(
3244
Resolver.mavenLocal,
3345
Resolver.sonatypeRepo("snapshots"),
3446
Resolver.sonatypeRepo("releases")
3547
),
3648
scalacOptions := scalacCommonOptions ++ scalacLanguageOptions,
37-
headers := Map(
38-
"scala" -> (HeaderPattern.cStyleBlockComment,
39-
s"""|/*
40-
| * scala-exercises - ${name.value}
41-
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
42-
| */
43-
|
44-
|""".stripMargin)
45-
)
49+
headerLicense := Some(Custom(s"""| scala-exercises - ${name.value}
50+
| Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
51+
|
52+
|""".stripMargin))
4653
)
4754
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.13
1+
sbt.version=1.2.8

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ resolvers ++= Seq(
22
Resolver.sonatypeRepo("snapshots")
33
)
44

5-
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
6-
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.5.13")
5+
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.5.0-SNAPSHOT")
6+
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3")

src/main/scala/fpinscalalib/ErrorHandlingSection.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib

src/main/scala/fpinscalalib/FPinScalaLibrary.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib

src/main/scala/fpinscalalib/FunctionalDataStructuresSection.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib
78

89
import org.scalatest.{FlatSpec, Matchers}
9-
import fpinscalalib.customlib._
1010
import fpinscalalib.customlib.functionaldatastructures._
1111
import fpinscalalib.customlib.functionaldatastructures.List._
1212
import Tree._

src/main/scala/fpinscalalib/FunctionalParallelismSection.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib
78

8-
import java.util.concurrent.ExecutorService
9-
109
import fpinscalalib.customlib.functionalparallelism.Par
1110
import fpinscalalib.customlib.functionalparallelism.Par._
1211
import org.scalatest.{FlatSpec, Matchers}

src/main/scala/fpinscalalib/FunctionalStateSection.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib
78

89
import fpinscalalib.customlib.state.RNG.Simple
910
import fpinscalalib.customlib.state.RNG._
1011
import org.scalatest.{FlatSpec, Matchers}
11-
import org.scalacheck.Shapeless._
1212
import fpinscalalib.customlib.state._
1313

1414
/** @param name pure_functional_state

src/main/scala/fpinscalalib/GettingStartedWithFPSection.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib

src/main/scala/fpinscalalib/ParserCombinatorsSection.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib
78

89
import org.scalatest.{FlatSpec, Matchers}
9-
import fpinscalalib.customlib.parsing.{JSON, Location, ParseError, Reference}
10+
import fpinscalalib.customlib.parsing.{JSON, ParseError, Reference}
1011
import fpinscalalib.customlib.parsing.ReferenceTypes._
1112
import Reference._
1213
import scala.util.matching.Regex
1314

14-
/** @param name parser_combinators
15+
/** @param name parser_combinatorss
1516
*/
1617
object ParserCombinatorsSection
1718
extends FlatSpec

src/main/scala/fpinscalalib/PropertyBasedTestingSection.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib
78

8-
import java.util.concurrent.Executors
9-
10-
import fpinscalalib.customlib.functionalparallelism.Par
119
import fpinscalalib.customlib.state.{RNG, State}
1210
import org.scalatest.{FlatSpec, Matchers}
13-
import fpinscalalib.customlib.testing.{Gen, Prop, SGen}
11+
import fpinscalalib.customlib.testing.{Gen, SGen}
1412
import fpinscalalib.customlib.testing.Gen._
1513
import fpinscalalib.customlib.testing.Prop._
1614

src/main/scala/fpinscalalib/StrictnessAndLazinessSection.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib
@@ -9,7 +10,6 @@ import fpinscalalib.customlib.laziness._
910
import fpinscalalib.customlib.laziness.Stream
1011
import fpinscalalib.customlib.laziness.Stream._
1112
import org.scalatest.{FlatSpec, Matchers}
12-
import fpinscalalib.customlib.laziness.ExampleHelper._
1313

1414
/** @param name strictness_and_laziness
1515
*/

src/main/scala/fpinscalalib/customlib/errorhandling/EitherHelper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.errorhandling

src/main/scala/fpinscalalib/customlib/errorhandling/ExampleHelper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.errorhandling

src/main/scala/fpinscalalib/customlib/errorhandling/OptionHelper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.errorhandling

src/main/scala/fpinscalalib/customlib/functionaldatastructures/ListHelper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.functionaldatastructures

src/main/scala/fpinscalalib/customlib/functionaldatastructures/TreeHelper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.functionaldatastructures

src/main/scala/fpinscalalib/customlib/functionalparallelism/ParHelper.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.functionalparallelism
@@ -148,7 +149,6 @@ object Par {
148149
}
149150

150151
object Examples {
151-
import Par._
152152
def sum(ints: IndexedSeq[Int]): Int = // `IndexedSeq` is a superclass of random-access sequences like `Vector` in the standard library. Unlike lists, these sequences provide an efficient `splitAt` method for dividing them into two parts at a particular index.
153153
if (ints.size <= 1)
154154
ints.headOption getOrElse 0 // `headOption` is a method defined on all collections in Scala. We saw this function in chapter 3.

src/main/scala/fpinscalalib/customlib/laziness/ExampleHelper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.laziness

src/main/scala/fpinscalalib/customlib/laziness/StreamHelper.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.laziness
@@ -160,16 +161,16 @@ trait Stream[+A] {
160161
def zipWithAll[B, C](s2: Stream[B])(f: (Option[A], Option[B]) => C): Stream[C] =
161162
Stream.unfold((this, s2)) {
162163
case (Empty, Empty) => None
163-
case (Cons(h, t), Empty) => Some(f(Some(h()), Option.empty[B]) -> (t(), empty[B]))
164+
case (Cons(h, t), Empty) => Some(f(Some(h()), Option.empty[B]) -> Tuple2(t(), empty[B]))
164165
case (Empty, Cons(h, t)) => Some(f(Option.empty[A], Some(h())) -> (empty[A] -> t()))
165166
case (Cons(h1, t1), Cons(h2, t2)) => Some(f(Some(h1()), Some(h2())) -> (t1() -> t2()))
166167
}
167168

168169
/*
169170
`s startsWith s2` when corresponding elements of `s` and `s2` are all equal, until the point that `s2` is exhausted. If `s` is exhausted first, or we find an element that doesn't match, we terminate early. Using non-strictness, we can compose these three separate logical steps--the zipping, the termination when the second stream is exhausted, and the termination if a nonmatching element is found or the first stream is exhausted.
170171
*/
171-
def startsWith[A](s: Stream[A]): Boolean =
172-
zipAll(s).takeWhile(!_._2.isEmpty) forAll {
172+
def startsWith[T](s: Stream[T]): Boolean =
173+
zipAll(s).takeWhile(_._2.isDefined) forAll {
173174
case (h, h2) => h == h2
174175
}
175176

@@ -182,7 +183,7 @@ trait Stream[+A] {
182183
case s => Some((s, s drop 1))
183184
} append Stream(empty)
184185

185-
def hasSubsequence[A](s: Stream[A]): Boolean =
186+
def hasSubsequence[T](s: Stream[T]): Boolean =
186187
tails exists (_ startsWith s)
187188

188189
/*

src/main/scala/fpinscalalib/customlib/parsing/JSON.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.parsing

src/main/scala/fpinscalalib/customlib/parsing/ParsersHelper.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* scala-exercises - exercises-fpinscala
3-
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
2+
* scala-exercises - exercises-fpinscala
3+
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
4+
*
45
*/
56

67
package fpinscalalib.customlib.parsing
@@ -200,7 +201,7 @@ case class Location(input: String, offset: Int = 0) {
200201

201202
/* Returns the line corresponding to this location */
202203
def currentLine: String =
203-
if (input.length > 1) input.lines.drop(line - 1).next
204+
if (input.length > 1) input.linesIterator.drop(line - 1).next
204205
else ""
205206

206207
def columnCaret = (" " * (col - 1)) + "^"

0 commit comments

Comments
 (0)