Skip to content
Permalink
Browse files

Updated Scala version and dependencies

  • Loading branch information
kiroco12 committed Nov 20, 2019
1 parent 491ce39 commit 72796f2b282deb1acc0dab5721593d3f97210f19
Showing with 250 additions and 233 deletions.
  1. +1 −1 .travis.yml
  2. +6 −4 build.sbt
  3. +20 −12 project/ProjectPlugin.scala
  4. +1 −1 project/build.properties
  5. +2 −2 project/plugins.sbt
  6. +3 −2 src/main/scala/fpinscalalib/ErrorHandlingSection.scala
  7. +3 −2 src/main/scala/fpinscalalib/FPinScalaLibrary.scala
  8. +3 −3 src/main/scala/fpinscalalib/FunctionalDataStructuresSection.scala
  9. +3 −4 src/main/scala/fpinscalalib/FunctionalParallelismSection.scala
  10. +3 −3 src/main/scala/fpinscalalib/FunctionalStateSection.scala
  11. +3 −2 src/main/scala/fpinscalalib/GettingStartedWithFPSection.scala
  12. +5 −4 src/main/scala/fpinscalalib/ParserCombinatorsSection.scala
  13. +4 −6 src/main/scala/fpinscalalib/PropertyBasedTestingSection.scala
  14. +3 −3 src/main/scala/fpinscalalib/StrictnessAndLazinessSection.scala
  15. +3 −2 src/main/scala/fpinscalalib/customlib/errorhandling/EitherHelper.scala
  16. +3 −2 src/main/scala/fpinscalalib/customlib/errorhandling/ExampleHelper.scala
  17. +3 −2 src/main/scala/fpinscalalib/customlib/errorhandling/OptionHelper.scala
  18. +3 −2 src/main/scala/fpinscalalib/customlib/functionaldatastructures/ListHelper.scala
  19. +3 −2 src/main/scala/fpinscalalib/customlib/functionaldatastructures/TreeHelper.scala
  20. +3 −3 src/main/scala/fpinscalalib/customlib/functionalparallelism/ParHelper.scala
  21. +3 −2 src/main/scala/fpinscalalib/customlib/laziness/ExampleHelper.scala
  22. +7 −6 src/main/scala/fpinscalalib/customlib/laziness/StreamHelper.scala
  23. +3 −2 src/main/scala/fpinscalalib/customlib/parsing/JSON.scala
  24. +4 −3 src/main/scala/fpinscalalib/customlib/parsing/ParsersHelper.scala
  25. +4 −4 src/main/scala/fpinscalalib/customlib/parsing/Reference.scala
  26. +3 −2 src/main/scala/fpinscalalib/customlib/state/StateHelper.scala
  27. +3 −2 src/main/scala/fpinscalalib/customlib/testing/GenHelper.scala
  28. +19 −18 src/test/scala/fpinscalalib/ErrorHandlingSpec.scala
  29. +29 −30 src/test/scala/fpinscalalib/FunctionalDataStructuresSpec.scala
  30. +15 −15 src/test/scala/fpinscalalib/FunctionalParalellismSpec.scala
  31. +13 −16 src/test/scala/fpinscalalib/FunctionalStateSpec.scala
  32. +12 −14 src/test/scala/fpinscalalib/GettingStartedWithFPSpec.scala
  33. +15 −14 src/test/scala/fpinscalalib/ParserCombinatorsSpec.scala
  34. +17 −18 src/test/scala/fpinscalalib/PropertyBasedTestingSpec.scala
  35. +24 −24 src/test/scala/fpinscalalib/StrictnessAndLazinessSpec.scala
  36. +1 −1 version.sbt
@@ -1,6 +1,6 @@
language: scala
scala:
- 2.11.11
- 2.12.10
jdk:
- openjdk8
script:
@@ -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

@@ -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
)
)

@@ -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,23 +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")
),
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))
)
}
@@ -1 +1 @@
sbt.version=0.13.13
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-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
@@ -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
@@ -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._
@@ -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}
@@ -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
@@ -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
@@ -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
@@ -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._

@@ -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
@@ -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
*/
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.
@@ -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
@@ -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
@@ -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
}

@@ -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)

/*
@@ -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
@@ -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
@@ -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)) + "^"

0 comments on commit 72796f2

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