Skip to content

Update to Scala 2.12.10 #48

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 4 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
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.12.10
jdk:
- openjdk8
script:
Expand Down
10 changes: 6 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
val scalaExercisesV = "0.4.0-SNAPSHOT"
import ProjectPlugin.autoImport._
val scalaExercisesV = "0.5.0-SNAPSHOT"

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

Expand All @@ -9,9 +10,10 @@ lazy val fpinscala = (project in file("."))
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("scalatest"),
%%("scalacheck"),
%%("scheckShapeless")
%%("shapeless", V.shapeless),
%%("scalatest", V.scalatest),
%%("scalacheck", V.scalacheck),
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % V.scalacheckShapeless
)
)

Expand Down
32 changes: 20 additions & 12 deletions project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
@@ -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._
Expand All @@ -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",
Expand All @@ -25,23 +39,17 @@ object ProjectPlugin extends AutoPlugin {
organizationEmail = "[email protected]"
),
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")
),
scalacOptions := scalacCommonOptions ++ scalacLanguageOptions,
headers := Map(
"scala" -> (HeaderPattern.cStyleBlockComment,
s"""|/*
| * scala-exercises - ${name.value}
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
| */
|
|""".stripMargin)
)
headerLicense := Some(Custom(s"""| scala-exercises - ${name.value}
| Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
|
|""".stripMargin))
)
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.13
sbt.version=1.2.8
4 changes: 2 additions & 2 deletions 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.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")
5 changes: 3 additions & 2 deletions src/main/scala/fpinscalalib/ErrorHandlingSection.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/fpinscalalib/FPinScalaLibrary.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib

import org.scalatest.{FlatSpec, Matchers}
import fpinscalalib.customlib._
import fpinscalalib.customlib.functionaldatastructures._
import fpinscalalib.customlib.functionaldatastructures.List._
import Tree._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib

import java.util.concurrent.ExecutorService

import fpinscalalib.customlib.functionalparallelism.Par
import fpinscalalib.customlib.functionalparallelism.Par._
import org.scalatest.{FlatSpec, Matchers}
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/fpinscalalib/FunctionalStateSection.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib

import fpinscalalib.customlib.state.RNG.Simple
import fpinscalalib.customlib.state.RNG._
import org.scalatest.{FlatSpec, Matchers}
import org.scalacheck.Shapeless._
import fpinscalalib.customlib.state._

/** @param name pure_functional_state
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/fpinscalalib/GettingStartedWithFPSection.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib
Expand Down
9 changes: 5 additions & 4 deletions src/main/scala/fpinscalalib/ParserCombinatorsSection.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib

import org.scalatest.{FlatSpec, Matchers}
import fpinscalalib.customlib.parsing.{JSON, Location, ParseError, Reference}
import fpinscalalib.customlib.parsing.{JSON, ParseError, Reference}
import fpinscalalib.customlib.parsing.ReferenceTypes._
import Reference._
import scala.util.matching.Regex

/** @param name parser_combinators
/** @param name parser_combinatorss
*/
object ParserCombinatorsSection
extends FlatSpec
Expand Down
10 changes: 4 additions & 6 deletions src/main/scala/fpinscalalib/PropertyBasedTestingSection.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib

import java.util.concurrent.Executors

import fpinscalalib.customlib.functionalparallelism.Par
import fpinscalalib.customlib.state.{RNG, State}
import org.scalatest.{FlatSpec, Matchers}
import fpinscalalib.customlib.testing.{Gen, Prop, SGen}
import fpinscalalib.customlib.testing.{Gen, SGen}
import fpinscalalib.customlib.testing.Gen._
import fpinscalalib.customlib.testing.Prop._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib
Expand All @@ -9,7 +10,6 @@ import fpinscalalib.customlib.laziness._
import fpinscalalib.customlib.laziness.Stream
import fpinscalalib.customlib.laziness.Stream._
import org.scalatest.{FlatSpec, Matchers}
import fpinscalalib.customlib.laziness.ExampleHelper._

/** @param name strictness_and_laziness
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.errorhandling
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.errorhandling
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.errorhandling
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.functionaldatastructures
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.functionaldatastructures
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.functionalparallelism
Expand Down Expand Up @@ -148,7 +149,6 @@ object Par {
}

object Examples {
import Par._
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.
if (ints.size <= 1)
ints.headOption getOrElse 0 // `headOption` is a method defined on all collections in Scala. We saw this function in chapter 3.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.laziness
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.laziness
Expand Down Expand Up @@ -160,16 +161,16 @@ trait Stream[+A] {
def zipWithAll[B, C](s2: Stream[B])(f: (Option[A], Option[B]) => C): Stream[C] =
Stream.unfold((this, s2)) {
case (Empty, Empty) => None
case (Cons(h, t), Empty) => Some(f(Some(h()), Option.empty[B]) -> (t(), empty[B]))
case (Cons(h, t), Empty) => Some(f(Some(h()), Option.empty[B]) -> Tuple2(t(), empty[B]))
case (Empty, Cons(h, t)) => Some(f(Option.empty[A], Some(h())) -> (empty[A] -> t()))
case (Cons(h1, t1), Cons(h2, t2)) => Some(f(Some(h1()), Some(h2())) -> (t1() -> t2()))
}

/*
`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.
*/
def startsWith[A](s: Stream[A]): Boolean =
zipAll(s).takeWhile(!_._2.isEmpty) forAll {
def startsWith[T](s: Stream[T]): Boolean =
zipAll(s).takeWhile(_._2.isDefined) forAll {
case (h, h2) => h == h2
}

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

def hasSubsequence[A](s: Stream[A]): Boolean =
def hasSubsequence[T](s: Stream[T]): Boolean =
tails exists (_ startsWith s)

/*
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/fpinscalalib/customlib/parsing/JSON.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

package fpinscalalib.customlib.parsing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
* scala-exercises - exercises-fpinscala
* Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
*
*/

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

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

def columnCaret = (" " * (col - 1)) + "^"
Expand Down
Loading