Skip to content

Instantly share code, notes, and snippets.

@jamie-allen
Last active October 7, 2016 23:39
Show Gist options
  • Select an option

  • Save jamie-allen/8412227e377ba2c64669aa31c42814ac to your computer and use it in GitHub Desktop.

Select an option

Save jamie-allen/8412227e377ba2c64669aa31c42814ac to your computer and use it in GitHub Desktop.
scala> import cats._, cats.instances.all._
import cats._
import cats.instances.all._
scala> :paste
// Entering paste mode (ctrl-D to finish)
sealed trait TrafficLight
object TrafficLight {
def red: TrafficLight = Red
def yellow: TrafficLight = Yellow
def green: TrafficLight = Green
case object Red extends TrafficLight
case object Yellow extends TrafficLight
case object Green extends TrafficLight
}
// Exiting paste mode, now interpreting.
defined trait TrafficLight
defined object TrafficLight
scala> :paste
// Entering paste mode (ctrl-D to finish)
implicit val trafficLightEq: Eq[TrafficLight] =
new Eq[TrafficLight] {
def eqv(a1: TrafficLight, a2: TrafficLight): Boolean = a1 == a2
}
// Exiting paste mode, now interpreting.
trafficLightEq: cats.Eq[TrafficLight] = $anon$1@2a588f49
scala> TrafficLight.red === TrafficLight.yellow
<console>:32: error: value === is not a member of TrafficLight
TrafficLight.red === TrafficLight.yellow
^
scala>
val catsVersion = "0.7.2"
val catsAll = "org.typelevel" %% "cats" % catsVersion
val macroParadise = compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
val kindProjector = compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.0")
val resetAllAttrs = "org.scalamacros" %% "resetallattrs" % "1.0.0-M1"
val specs2Version = "3.8.5" // use the version used by discipline
val specs2Core = "org.specs2" %% "specs2-core" % specs2Version
val specs2Scalacheck = "org.specs2" %% "specs2-scalacheck" % specs2Version
val scalacheck = "org.scalacheck" %% "scalacheck" % "1.13.2"
lazy val root = (project in file(".")).
settings(
organization := "com.jamieallen",
name := "cats-playground",
scalaVersion := "2.11.8",
libraryDependencies ++= Seq(
catsAll,
specs2Core % Test, specs2Scalacheck % Test, scalacheck % Test,
macroParadise, kindProjector, resetAllAttrs
),
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:_"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment