Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDavenport committed May 10, 2018
0 parents commit 29b4f4c
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
target/
.idea/
# vim
*.sw?

# Ignore [ce]tags files
tags
25 changes: 25 additions & 0 deletions .scalafmt.conf
@@ -0,0 +1,25 @@
# tune this file as appropriate to your style! see: https://olafurpg.github.io/scalafmt/#Configuration

maxColumn = 100

continuationIndent.callSite = 2

newlines {
sometimesBeforeColonInMethodReturnType = false
}

align {
arrowEnumeratorGenerator = false
ifWhileOpenParen = false
openParenCallSite = false
openParenDefnSite = false

tokens = ["%", "%%"]
}

docstrings = JavaDoc

rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}
19 changes: 19 additions & 0 deletions .travis.yml
@@ -0,0 +1,19 @@
sudo: false
language: scala

scala:
- 2.12.6
- 2.11.12

before_cache:
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete

cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.coursier/cache
- $HOME/.sbt

jdk:
- oraclejdk8
2 changes: 2 additions & 0 deletions README.md
@@ -0,0 +1,2 @@
# cats-scalacheck

101 changes: 101 additions & 0 deletions build.sbt
@@ -0,0 +1,101 @@
lazy val core = project.in(file("."))
.settings(commonSettings)
.settings(
name := "cats-scalacheck"
)

val catsV = "1.1.0"
val scalacheckV = "1.14.0"


val specs2V = "4.2.0"
val disciplineV = "0.8"


lazy val contributors = Seq(
"ChristopherDavenport" -> "Christopher Davenport"
)

lazy val commonSettings = Seq(
organization := "io.chrisdavenport",

scalaVersion := "2.12.6",
crossScalaVersions := Seq(scalaVersion.value, "2.11.12"),

addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.6" cross CrossVersion.binary),

libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsV,
"org.scalacheck" %% "scalacheck" % scalacheckV,

"org.specs2" %% "specs2-core" % specs2V % Test,
"org.specs2" %% "specs2-scalacheck" % specs2V % Test,
"org.typelevel" %% "discipline" % disciplineV % Test
)
)

lazy val releaseSettings = {
import ReleaseTransformations._
Seq(
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
credentials ++= (
for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield
Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)
).toSeq,
publishArtifact in Test := false,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/ChristopherDavenport/cats-scalacheck"),
"git@github.com:ChristopherDavenport/cats-scalacheck.git"
)
),
homepage := Some(url("https://github.com/ChristopherDavenport/cats-scalacheck")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
pomIncludeRepository := { _ =>
false
},
pomExtra := {
<developers>
{for ((username, name) <- contributors) yield
<developer>
<id>{username}</id>
<name>{name}</name>
<url>http://github.com/{username}</url>
</developer>
}
</developers>
}
)
}
1 change: 1 addition & 0 deletions project/build.properties
@@ -0,0 +1 @@
sbt.version=1.1.5
8 changes: 8 additions & 0 deletions project/plugins.sbt
@@ -0,0 +1,8 @@
addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.3")
addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.0")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.8")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
5 changes: 5 additions & 0 deletions src/main/scala/org/scalacheck/cats/implicits/implicits.scala
@@ -0,0 +1,5 @@
package org.scalacheck.cats

import org.scalacheck.cats.instances.GenInstances

package object implicits extends GenInstances
46 changes: 46 additions & 0 deletions src/main/scala/org/scalacheck/cats/instances/gen.scala
@@ -0,0 +1,46 @@
package org.scalacheck.cats.instances

import cats._
import cats.implicits._
import org.scalacheck.Gen

object GenInstances extends GenInstances

trait GenInstances extends GenInstances1

sealed private[instances] trait GenInstances1 extends GenInstances0 {
implicit val genInstances : Monad[Gen] with SemigroupK[Gen] = new Monad[Gen] with Alternative[Gen] {
// Members declared in cats.Applicative
override def pure[A](x: A): Gen[A] = Gen.const(x)

// Members declared in cats.FlatMap
override def flatMap[A, B](fa: Gen[A])(f: A => Gen[B]): Gen[B] = fa.flatMap(f)
override def tailRecM[A, B](a: A)(f: A => Gen[Either[A,B]]): Gen[B] = Gen.tailRecM(a)(f)

override def combineK[A](x: Gen[A], y: Gen[A]): Gen[A] = Gen.gen{ (params, seed) =>
val xGen = x.doApply(params, seed)
if (xGen.retrieve.isDefined) xGen
else y.doApply(params, seed)
}

override def empty[A]: Gen[A] = Gen.fail
}

implicit def genMonoid[A: Monoid]: Monoid[Gen[A]] = new Monoid[Gen[A]]{
override def empty: Gen[A] = Gen.const(Monoid[A].empty)
override def combine(x: Gen[A], y: Gen[A]) = for {
xa <- x
ya <- y
} yield xa |+| ya
}

}

sealed private[instances] trait GenInstances0 {
implicit def genSemigroup[A: Semigroup]: Semigroup[Gen[A]] = new Semigroup[Gen[A]]{
override def combine(x: Gen[A], y: Gen[A]) = for {
xa <- x
ya <- y
} yield xa |+| ya
}
}
1 change: 1 addition & 0 deletions version.sbt
@@ -0,0 +1 @@
version in ThisBuild := "0.0.1-SNAPSHOT"

0 comments on commit 29b4f4c

Please sign in to comment.