scalacheck


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

org.typelevel
ArtifactId

ArtifactId

shapeless-scalacheck_2.12
Last Version

Last Version

0.6.1
Release Date

Release Date

Type

Type

jar
Description

Description

scalacheck
scalacheck
Project URL

Project URL

http://typelevel.org/
Project Organization

Project Organization

org.typelevel
Source Code Management

Source Code Management

https://github.com/typelevel/shapeless-contrib

Download shapeless-scalacheck_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/org.typelevel/shapeless-scalacheck_2.12/ -->
<dependency>
    <groupId>org.typelevel</groupId>
    <artifactId>shapeless-scalacheck_2.12</artifactId>
    <version>0.6.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.typelevel/shapeless-scalacheck_2.12/
implementation 'org.typelevel:shapeless-scalacheck_2.12:0.6.1'
// https://jarcasting.com/artifacts/org.typelevel/shapeless-scalacheck_2.12/
implementation ("org.typelevel:shapeless-scalacheck_2.12:0.6.1")
'org.typelevel:shapeless-scalacheck_2.12:jar:0.6.1'
<dependency org="org.typelevel" name="shapeless-scalacheck_2.12" rev="0.6.1">
  <artifact name="shapeless-scalacheck_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.typelevel', module='shapeless-scalacheck_2.12', version='0.6.1')
)
libraryDependencies += "org.typelevel" % "shapeless-scalacheck_2.12" % "0.6.1"
[org.typelevel/shapeless-scalacheck_2.12 "0.6.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.2
org.typelevel : shapeless-contrib-common_2.12 jar 0.6.1
com.chuusai : shapeless_2.12 jar 2.3.2
org.scalacheck : scalacheck_2.12 jar 1.13.5

Project Modules

There are no modules declared in this project.

shapeless-contrib

Interoperability libraries for Shapeless

Build Status

Usage

This library is currently available for Scala 2.10, 2.11, and 2.12.

To use the latest version, include the following in your build.sbt:

libraryDependencies ++= Seq(
  "org.typelevel" %% "shapeless-scalacheck" % "0.6.1",
  "org.typelevel" %% "shapeless-spire" % "0.6.1",
  "org.typelevel" %% "shapeless-scalaz" % "0.6.1"
)

What does this library do?

shapeless-contrib aims to provide smooth interoperability between Shapeless, and Spire. The most prominent feature is automatic derivation of type class instances for case classes, but there is more. If you've got a cool idea for more stuff, please open an issue.

Examples

Derive type classes

Consider a simple case class with an addition operation:

case class Vector3(x: Int, y: Int, z: Int) {
  def +(other: Vector3) = Vector3(this.x + other.x, this.y + other.y, this.z + other.z)
}

If we want to use that in a generic setting, e.g. in an algorithm which requires a Monoid, we can define an instance for spire.algebra.Monoid like so:

implicit object Vector3Monoid extends Monoid[Vector3] {
  def id = Vector3(0, 0, 0)
  def op(x: Vector3, y: Vector3) = x + y
}

This will work nicely for that particular case. However, it requires repetition: addition on Vector3 is just pointwise addition of its elements, and the null vector consists of three zeroes. We do not want to repeat that sort of code for all our case classes, and want to derive that automatically. Luckily, this library provides exactly that:

import spire.implicits._
import shapeless.contrib.spire._

// Define the `Vector3` case class without any operations
case class Vector3(x: Int, y: Int, z: Int)

// That's it! `Vector3` is an `AdditiveMonoid` now.
Vector3(1, 2, 3) + Vector3(-1, 3, 0)
org.typelevel

typelevel.scala

Let the Scala compiler work for you.

Versions

Version
0.6.1