Skip to content

Upgrades #1

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 3 commits into from
Nov 23, 2018
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
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.5
- 2.12.7

jdk:
- openjdk6
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ which is handy when working on a particular exercise:
./sbt

# Run the tests from a package containing the name "Id"
> testOnly "*Id*"
> testOnly *Id*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason testOnly wasn't working when these things were quoted.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not sure why I put the quotes in 👍


# Add a ~ for starting a watch daemon to recompile and re-run tests when files are changed
> ~testOnly "*Result*"
> ~testOnly *Result*


## Working with scala.
Expand Down
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name := "introduction-to-fp-in-scala"

scalaVersion := "2.11.5"
scalaVersion := "2.12.7"

libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-core" % "7.1.1"
, "org.scalaz" %% "scalaz-scalacheck-binding" % "7.1.1" % "test"
, "org.scalaz.stream" %% "scalaz-stream" % "0.6a"
, "org.specs2" %% "specs2" % "2.4.5" % "test"
, "org.scalacheck" %% "scalacheck" % "1.12.2" % "test"
"org.scalaz" %% "scalaz-core" % "7.2.27"
, "org.scalaz" %% "scalaz-scalacheck-binding" % "7.2.27-scalacheck-1.14" % "test"
, "org.scalaz.stream" %% "scalaz-stream" % "0.8.6a"
, "org.specs2" %% "specs2" % "3.8.9" % "test" exclude("org.specs2", "specs2-cats_2.12")
, "org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
)

resolvers ++= Seq(
Expand All @@ -20,9 +20,9 @@ scalacOptions := Seq(
"-deprecation"
, "-unchecked"
, "-Xfatal-warnings"
, "-Xlint"
, "-Xlint:_,-unused"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want unused errors because the exercises import useful things but don't use them (until the exercises are implemented)

, "-feature"
, "-language:_"
)

addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7")
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.8")
6 changes: 3 additions & 3 deletions sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ declare -r latest_28="2.8.2"

declare -r buildProps="project/build.properties"

declare -r sbt_launch_ivy_release_repo="https://repo.typesafe.com/typesafe/ivy-releases"
declare -r sbt_launch_ivy_release_repo="http://repo.typesafe.com/typesafe/ivy-releases"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I redownloaded the sbt script. Weird change, happy to undo.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I manually changed them to https, I don't know why Paul would want it to be http. We should probably push that change upstream.

declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy-snapshots"
declare -r sbt_launch_mvn_release_repo="https://repo.scala-sbt.org/scalasbt/maven-releases"
declare -r sbt_launch_mvn_snapshot_repo="https://repo.scala-sbt.org/scalasbt/maven-snapshots"
declare -r sbt_launch_mvn_release_repo="http://repo.scala-sbt.org/scalasbt/maven-releases"
declare -r sbt_launch_mvn_snapshot_repo="http://repo.scala-sbt.org/scalasbt/maven-snapshots"

declare -r default_jvm_opts_common="-Xms512m -Xss2m"
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/intro/Scala.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Scala {
/* sbt & repl */


/* clases & objects */
/* classes & objects */


/* methods, values */
Expand Down
64 changes: 40 additions & 24 deletions src/test/scala/intro/MonoidSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,45 @@ import test._

object MonoidSpecification extends Properties("Monoid") {

property("monoid: sum") =
monoidLaws(Monoid.SumMonoid, arbitrary[Int].map(Sum))

property("monoid: product") =
monoidLaws(Monoid.ProductMonoid, arbitrary[Int].map(Product))

property("monoid: min") =
monoidLaws(Monoid.MinMonoid, arbitrary[Int].map(Min))

property("monoid: max") =
monoidLaws(Monoid.MaxMonoid, arbitrary[Int].map(Max))

property("monoid: first") =
monoidLaws(Monoid.FirstMonoid[Int], arbitrary[Option[Int]].map(First(_)))

property("monoid: last") =
monoidLaws(Monoid.LastMonoid[Int], arbitrary[Option[Int]].map(Last(_)))

property("monoid: list") =
monoidLaws(Monoid.ListMonoid[Int], arbitrary[List[Int]])

property("monoid: map") =
monoidLaws(Monoid.MapMonoid[Int, List[Int]], arbitrary[Map[Int, List[Int]]])
include(
monoidLaws(Monoid.SumMonoid, arbitrary[Int].map(Sum)),
"monoid: sum"
)

include(
monoidLaws(Monoid.ProductMonoid, arbitrary[Int].map(Product)),
"monoid: product"
)

include(
monoidLaws(Monoid.MinMonoid, arbitrary[Int].map(Min)),
"monoid: min"
)

include(
monoidLaws(Monoid.MaxMonoid, arbitrary[Int].map(Max)),
"monoid: max"
)

include(
monoidLaws(Monoid.FirstMonoid[Int], arbitrary[Option[Int]].map(First(_))),
"monoid: first"
)

include(
monoidLaws(Monoid.LastMonoid[Int], arbitrary[Option[Int]].map(Last(_))),
"monoid: last"
)

include(
monoidLaws(Monoid.ListMonoid[Int], arbitrary[List[Int]]),
"monoid: list"
)

include(
monoidLaws(Monoid.MapMonoid[Int, List[Int]], arbitrary[Map[Int, List[Int]]]),
"monoid: map"
)

property("monoid: foldMap sum") =
Monoid.foldMap(List(1, 2, 3, 4, 5))(x => Sum(x)) ?= Sum(15)
Expand All @@ -38,7 +54,7 @@ object MonoidSpecification extends Properties("Monoid") {
property("monoid: sum") =
Monoid.sum(List(1, 2, 3, 4, 5).map(Sum)) ?= Sum(15)

def monoidLaws[A](m: Monoid[A], gen: Gen[A]): Prop =
def monoidLaws[A](m: Monoid[A], gen: Gen[A]): Properties =
new Properties("MonoidLaws") {

property("left identity") =
Expand Down