A Scala implementation of hedgehog using the typelevel libraries
Switch branches/tags
Nothing to show
Clone or download
Latest commit d9f1aae May 19, 2017
Failed to load latest commit information.
core Fix typos Apr 28, 2017
example first commit Apr 18, 2017
project move to sbt-travisci Apr 19, 2017
.travis.yml set java 8 for travis Apr 19, 2017
LICENSE first commit Apr 18, 2017
README.md fix Build Status link May 16, 2017
sonic.sbt move to sbt-travisci Apr 19, 2017



Build Status

Sonic is a Scala implementation of hedgehog using Cats and Monix. It is a direct translation of the haskell implementation. It's still in early stage and lacks many parts of the original library but the core data structures are all implemented and working.


  • Integrated shrinking, shrinks obey invariants by construction.
  • Generators allow monadic effects.
  • Range combinators for full control over the scope of generated numbers and collections.


You can find the following example in the subdirectory example.

Import sonic._, cats.syntax.flatMap._ and optionally sonic.syntax._.

import sonic._
import sonic.syntax._
import cats.syntax.flatMap._

Once you have your imports set up, you can write a simple property:

def propReverse =
      forAll(Gen.list(Range.linear(0, 100))(Gen.alpha)) >>=
      (list => list.reverse.reverse === list)

Then define a group containing the property that you have just defined:

def listPropertyGroups =
    "propReverse" -> propReverse

Finally, run the property group with Runner.checkGroup:

def main(args: Array[String]): Unit = {

and run the Scala program:

$ sbt example/run
━━━ example ━━━
  propReverse: true


Contributions are welcomed in the form of PRs.

People are expected to follow the Typelevel Code of Conduct when discussing sonic on the Github page, Gitter channel, or other venues.