Skip to content

0.8.5

Compare
Choose a tag to compare
@fthomas fthomas released this 19 Dec 19:08
· 1995 commits to master since this release
v0.8.5
bf1813a

New features

  • Add RefinedTypeOps to simplify the definition of a refined type's
    companion object and the RefinedType type class which combines
    RefType and Validate instances for a refined type. With the
    former a companion of a refined type can now defined like this:
    // 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)
    This change also adds companion objects for the refined types in
    the eu.timepit.refined.types package which simplifies creating
    values of these types a lot.
    (#342, #369, #193)
  • Support BigInt and BigDecimal literals in compile-time checks.
    For example, this is now possible:
    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")
                                                          ^
    Thanks to kusamakura!
    (#345)
  • Add IPv4 predicate for Strings 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 an Order instance.
    Thanks to Howy Perrin! (#376)
  • Add Validate[ByteVector, Size[P]] instance to the refined-scodec
    module. This allows to refine ByteVectors with the Size predicate,
    for example:
    scala> refineV[Size[Equal[W.`2L`.T]]](ByteVector.fromValidHex("0xabcd"))
    res0: Either[String, ByteVector Refined Size[Equal[Long(2L)]]] = Right(ByteVector(2 bytes, 0xabcd))
    (#365)
  • Add a TrimmedString refined type for Strings 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