0.8.5
New features
- Add
RefinedTypeOps
to simplify the definition of a refined type's
companion object and theRefinedType
type class which combines
RefType
andValidate
instances for a refined type. With the
former a companion of a refined type can now defined like this:This change also adds companion objects for the refined types in// definition of the refined type `PosInt` scala> type PosInt = Int Refined Positive // definition of the companion object for `PosInt` scala> object PosInt extends RefinedTypeOps[PosInt, Int] scala> PosInt(1) // create `PosInt`s from literals res0: PosInt = 1 scala> PosInt.from(2) // create `PosInt`s from runtime values res1: Either[String, PosInt] = Right(2)
theeu.timepit.refined.types
package which simplifies creating
values of these types a lot.
(#342, #369, #193) - Support
BigInt
andBigDecimal
literals in compile-time checks.
For example, this is now possible:Thanks to kusamakura!scala> val x: BigDecimal Refined Positive = BigDecimal("2E+500") x: BigDecimal Refined Positive = 2E+500 scala> val x: BigDecimal Refined Positive = BigDecimal("-2E+500") <console>:50: error: Predicate failed: (-2E+500 > 0). val x: BigDecimal Refined Positive = BigDecimal("-2E+500") ^
(#345) - Add
IPv4
predicate forString
s and refined types for private IPv4
addresses. Thanks to Tim Steinbach!
(#356) - Add
cats.Order
instance for any refined type whose base type has
also anOrder
instance.
Thanks to Howy Perrin! (#376) - Add
Validate[ByteVector, Size[P]]
instance to therefined-scodec
module. This allows to refineByteVector
s with theSize
predicate,
for example:(#365)scala> refineV[Size[Equal[W.`2L`.T]]](ByteVector.fromValidHex("0xabcd")) res0: Either[String, ByteVector Refined Size[Equal[Long(2L)]]] = Right(ByteVector(2 bytes, 0xabcd))
- Add a
TrimmedString
refined type forString
s without leading or
trailing whitespace. (#275)
Changes
- Split objects in
refined-scalacheck
into traits and objects for
easier reuse. Thanks to Nicolas Rinaudo!
(#343)
Updates
- Update
refined-cats
to Cats 1.0.0-RC2. (#375, #350) - Update to Scala.js 0.6.21. (#351)
- Update
refined-scalaz
to Scalaz 7.2.17. (#360)
Released on 2017-12-19