Common utility libraries for Scala, mostly small stuff I don't want to have multiple copies of lying around.
libraryDependencies += Seq( "com.github.morgen-peschke" % "commons-core" % "0.2.0", "com.github.morgen-peschke" % "commons-collections" % "0.2.0", "com.github.morgen-peschke" % "commons-decline" % "0.2.0", "com.github.morgen-peschke" % "commons-shims" % "0.2.0", "com.github.morgen-peschke" % "commons-scalacheck" % "0.2.0" % Test ) def ivyDeps = Agg( ivy"com.github.morgen-peschke::commons-core:0.2.0", ivy"com.github.morgen-peschke::commons-collections:0.2.0", ivy"com.github.morgen-peschke::commons-decline:0.2.0", ivy"com.github.morgen-peschke::commons-shims:0.2.0", ivy"com.github.morgen-peschke::commons-scalacheck:0.2.0" ) This is a home for the most generic of utilities.
A placeholder indicating completion, which provides a work-around for the type issues which can arise when returning things like Future[Unit].
This is very similar to akka.Done, and exists as a lightweight alternative to the same.
A pure Scala, lightweight implementation of python's slice syntax (e.g [start:stop:step]).
Helpers and extensions for working with the Scala standard library.
An alternative to IterableOnce#takeWhile, which is primarily differentiated on two points:
- The elements are consumed until the predicate is true, rather than while the predicate is true, so the logic is reversed.
- The final element is also taken.
A collection of utilities and syntax to make working with Scalacheck Gen smoother.
Highlights include:
-
(0 to 10).chooseas a more flexible alternative toGen.chooseNum(0, 10)This is particularly handy because(a until b by c).chooseis equivalent to something closer to this:Gen.chooseNum(0, (b-a) - 1).map(l => a + (c * l))
-
RangeGens.ranges(min, max)generatesRanges within those bounds -
NumericRangeGens.numericRanges(min, max)generatesNumericRanges within those bounds -
(g: Gen[A]).as.list(a to b)as an alternative toGen.chooseNum(a, b).flatMap(Gen.listOfN(g, foo))Variants also exist to produce
Vector,Chain, and theNonEmpty*equivalents, as well as one to lift aGen[Char]into aGen[String] -
(g: Gen[A]).optionalas a chaining alternative toGen.option(g)
Instances for Decline, notably one for Slice as it tends to be very handy for CLI utilities.
Everything in this module has a better alternative in another library. If, however, you're not able to access the better version, this module aims to provide at least some comfort in the form of minimal dependency alternatives.
The primary example is Managed, which solves the same general problem as Java's try-with-resource construct, and is far better solved by cats.effect.Resource.