refined

Refinement types for Scala

MIT License

Stars
1.7K
Committers
76

Bot releases are hidden (Show)

refined - 0.9.9

Published by fthomas about 5 years ago

New features

  • Add Semigroup and Monoid instances for refined numeric types.
    (#618 by @dm-tran)

Build

  • Release all modules except refiend-cats and refined-scalacheck_1.13
    for Scala 2.13. (#658, #660 by @fthomas)

Updates

Released on 2019-07-27

refined - 0.9.8

Published by fthomas over 5 years ago

New features

Updates

Released on 2019-06-10

refined - 0.9.7

Published by fthomas over 5 years ago

Updates

Released on 2019-05-31

refined - 0.9.6

Published by fthomas over 5 years ago

Updates

Released on 2019-05-25

refined - 0.9.5

Published by fthomas over 5 years ago

Bug fixes

  • Add type parameter for the predicate type to auto.autoUnwrap in
    order to improve type inference.
    (#608, #612 by @fthomas)

Updates

Released on 2019-04-16

refined - 0.9.4

Published by fthomas over 5 years ago

New features

  • Add NonNaN predicate that checks if a floating-point is not NaN.
    (#596 by @dcastro)

Bug fixes

  • Move derivation instances for RefType into new cats.derivation
    and scalaz.derivation modules to fix "diverging implicit expansion"
    errors with wildcard imports of cats._ and scalaz._.
    (#554 by @fthomas)

Updates

Released on 2019-01-18

refined - 0.9.1

Published by fthomas almost 6 years ago

New features

  • Add new Trimmed predicate and use it to implement TrimmedString.
    This also adds TrimmedString.trim to create a TrimmedString from
    an arbitrary String and an Arbitrary instance for TrimmedString.
    (#504 by @ceedubs)
  • Add Arbitrary instances for NonEmpty Lists and Vectors.
    (#486 by @fthomas)
  • New predicates ValidByte, ValidShort, and ValidFloat that check
    if a String is a parsable Byte, Short, or Float.
    (#492 by @sh0hei)

Changes

  • Add tests for refined types.
    (#493 by @rider-yi)
  • Improve performance of RefinedType#unsafeFrom.
    (#499 by @fthomas)
  • A String containing line terminators is a valid TrimmedString.
    (#504 by @ceedubs)

Deprecations

  • Deprecate RefType#refineMF in favor of RefinedTypeOps.
    (#514 by @fthomas)

Updates

Released on 2018-06-27

refined - 0.9.2

Published by fthomas almost 6 years ago

Updates

  • Update refined-scalaz to Scalaz 7.2.25.
    (#536 by @fthomas)

Released on 2018-07-04

refined - 0.9.3

Published by fthomas almost 6 years ago

New features

  • Add refinedSize as extension method to cats.data.NonEmptyList
    that returns the size of the NonEmptyList as a PosInt.
    (#539 by @cb372)
  • Add refined types for Byte, Short, BigInt, and BigDecimal,
    like PosByte, NonNegByte, NegByte, etc.
    (#567 by @Michaelt293)
  • Add new refined-scalacheck_1.13 module which depends on ScalaCheck
    1.13 instead of ScalaCheck 1.14 which is used by refined-scalacheck.
    (#573 by @liff)

Changes

Updates

Documentation

Released on 2018-11-01

refined - 0.9.0

Published by fthomas over 6 years ago

New features

  • Type class derivation for refined types via Contravariant or
    MonadError instances of the respective type class. This allows,
    for example, to derive encoders and decoders for refined types
    via encoders and decoders of their base types.
    (#447 by @fommil for Scalaz and
    #449 by @fthomas for Cats)
  • Add Arbitrary instances for List, Vector, and String refined
    with any Size[P]. (#455, #471
    by @matthedude and @fthomas)
  • Add Arbitrary instance for NonEmptyString. (#415)
  • Add predicates package which allows to import all predicates
    with a single import eu.timepit.refined.predicates.all._.
    (#433)
  • Cross build the refined, refined-scalaz, and refined-shapeless
    modules for Scala Native. (#301, #478)
  • Add inference rules for Greater[N] ==> GreaterEqual[N] and
    Less[N] ==> LessEqual[N]. (#452 by @zainab-ali)
  • Add new refined-shapeless module that provides Typeable instances
    for refined types. (#456 by @umbreak)
  • Add new refined-scopt module for integration of refined types
    with scopt.
    (#457 by @nrinaudo)
  • Add HexString, MD5, SHA1, SHA224, SHA256, SHA384,
    and SHA512 types. (#453 by @NeQuissimus)
  • Add FiniteString[N] type for Strings with length less than or
    equal to N. (#437, #479)

Changes

  • Change layout of the types package to create fewer instances and to
    support "auto import" in IntelliJ. (#416, #431)
  • Move Validate instances into the companions of their respective
    predicate instead of a prefix because in a future Scala version
    prefixes might not be searched for implicits, see
    scala-dev/#446. (#438)
  • Update documentation to solve "exception during macro expansion" errors.
    (#451 by @umbreak)
  • Change the definition of MaxSize[N] from Size[LessEqual[N]] to
    Size[Interval.Closed[_0, N]] and introduce the WitnessAs type class
    which unifies numeric type class instances that were split to work with
    literal singleton types and shapeless.Nat.
    (#473, #483)

Deprecations and removals

  • Deprecate Subtype and Supertype predicates because they lack
    practical relevance. (#432)
  • Deprecate ConstructorNames and FieldNames predicates because they
    operate on types instead of values (i.e. the result of a validation
    only depends on the type of a value) and the library focuses on
    refining values. (#435)
  • Remove deprecated util.time module which has been replaced by
    the types.time module. (#425)
  • Remove deprecated Refined#get method which has been replaced by
    Refined#value. (#426)
  • Deprecate scalacheck.util.Adjacent in favor of internal.Adjacent
    in the core module. (#475)
  • Deprecate scalacheck.util.Bounded in favor of api.{Min, Max}
    in the core module. (#482)

Updates and build

  • Update refined-cats to Cats 1.1.0. (#467)
  • Update refined-scalaz to Scalaz 7.2.21. (#434, #468
    by @fthomas and @fommil)
  • Update to the latest travis_setup.sh for Scala Native.
    (#458 by @densh)

Released on 2018-04-22

refined - 0.8.7

Published by fthomas over 6 years ago

New features

  • Add MinValue and MaxValue to companions of numeric refined types
    via the new Min and Max type classes:
    scala> PosInt.MinValue
    res0: eu.timepit.refined.types.all.PosInt = 1
    
    scala> PosInt.MaxValue
    res1: eu.timepit.refined.types.all.PosInt = 2147483647
    
    Thanks to Howy Perrin! (#383)
  • Support Divisible[N] if N is a literal integral type. (#413)
  • Add floating-point refined types like PosDouble, NegDouble, and more
    to the eu.timepit.refined.types.numeric module.
    Thanks to Yuki Ishikawa! (#414)
  • Add IPv6 predicate for Strings.
    Thanks to Tim Steinbach! (#357)

Bug fixes

  • Fix Modulo predicate for large Long values by avoiding toDouble
    in its Validate instance. This also restricts the predicate to types
    with an Integral instance.
    Thanks to Howy Perrin! (#398)

Updates

  • Update to shapeless 2.3.3. (#399)
  • Update refined-cats to Cats 1.0.1. (#399)
  • Update refined-pureconfig to PureConfig 0.9.0.
    Thanks to Olli Helenius! (#410)
  • Update to Scala.js 0.6.22. (#417)

Released on 2018-01-28

refined - 0.8.6

Published by fthomas almost 7 years ago

New features

  • Add the validate method to companions of refined types to accumulate
    errors with cats.data.ValidatedNel. To use this method, syntax._
    from the refined-cats module needs to be imported like this:
    scala> import eu.timepit.refined.types.numeric.PosInt
    scala> import eu.timepit.refined.cats.syntax._
    
    scala> PosInt.validate(1)
    res0: cats.data.ValidatedNel[String,PosInt] = Valid(1)
    
    Thanks to Howy Perrin!
    (#382, #384)
  • Add the validate method using scalaz.ValidationNel also to the
    refined-scalaz module.
    Thanks to kusamakura! (#385)

New predicates

string

  • ValidInt: checks if a String is a parsable Int
  • ValidLong: checks if a String is a parsable Long
  • ValidDouble: checks if a String is a parsable Double
  • ValidBigInt: checks if a String is a parsable BigInt
  • ValidBigDecimal: checks if a String is a parsable BigDecimal

Thanks to kusamakura! (#379)

Performance improvements

  • Apply the optimization done in #334 also to macro calls that
    use RefineMacro.implApplyRef. Before this change, compilation time
    of e.g. PosInt(1) was one order of magnitude slower than 1: PosInt.
    With this change there is no difference in compilation times between
    these two calls. (#388)

Updates

  • Update refined-cats to Cats 1.0.0. (#390)

Released on 2017-12-27

refined - 0.8.5

Published by fthomas almost 7 years ago

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

refined - 0.8.4

Published by fthomas about 7 years ago

Performance improvements

  • Avoid calling eval in refine and infer macros for known RefType
    instances. This reduces compilation times by roughly 26% for all
    compile-time refinements with common predicates.
    (#332, #333)
  • Avoid calling eval in refine macros for a few Validate instances.
    In combination with the above change, this can reduce compilation times
    up to 67%. (#334)
  • Inline Validate.instance in the definition of Validate.fromPredicate.
    This makes refineV[Positive](x) for instance 25% faster. (#335)
  • Optimize Validate instances that are built with Validate.fromPartial.
    (#336)

Released on 2017-10-04

refined - 0.8.3

Published by fthomas about 7 years ago

New features

  • Add new port number types toeu.timepit.refined.types.net like
    SystemPortNumber and NonSystemPortNumber.
    Thanks to Shohei Shimomura!
    (#294 #304)
  • Add the refined-jsonpath subproject which provides the JSONPath
    predicate that checks if a String is a valid JSONPath.
    Thanks to Iurii Susuk! (#305)

Bug fixes

  • Tighten Validate instance for UUID by allowing only Strings of
    length 36 in the standard 8-4-4-4-12 representation.
    Thanks to Yuki Ishikawa!
    (#296, #300)

Updates

  • Update to Scala.js 0.6.20. (#290, #303, #303,
    #324)
  • Update refined-cats to Cats 1.0.0-MF.
    Thanks to Shohei Shimomura! (#311)
  • Update refined-scalaz to Scalaz 7.2.15. (#312)
  • Update refined-pureconfig to PureConfig 0.8.0. (#323)

Also many thanks to ronanM,
Leif Wickland, and
Richard Gomes for various improvements.

Released on 2017-09-06

refined - 0.8.2

Published by fthomas about 7 years ago

Changes

  • Add the refined-cats subproject which adds Eq and Show
    instances for any refined type.
    Thanks to Derek Morr!
    (#284)

Updates

  • Update refined-pureconfig to PureConfig 0.7.2.
    Thanks to Viktor Lövgren!
    (#283)
  • Update refined-scalaz to Scalaz 7.2.13. (#288)

Released on 2017-06-02

refined - 0.8.1

Published by fthomas about 7 years ago

New predicates

numeric

  • Modulo[N, O]: checks if a numeric value modulo N is O. (#278)
  • Divisible[N]: checks if a numeric value is evenly divisible by N. (#278)
  • NonDivisible[N]: checks if a numeric value is not evenly divisible by N. (#278)
  • Even: checks if a numeric value is evenly divisible by 2. (#278)
  • Odd: checks if a numeric value is not evenly divisible by 2. (#278)

Thanks to Viktor Lövgren for these predicates!

Updates

  • Update refined-pureconfig to PureConfig 0.7.0.
    Thanks to Torsten Scholak!
    (#273)
  • Update to Scala.js 0.6.16. (#270, #279)
  • Update refined-scalaz to Scalaz 7.2.12. (#281)

Released on 2017-05-08

refined - 0.8.0

Published by fthomas over 7 years ago

Changes

  • Improve MacroUtils.eval by calling duplicate before untypechecking
    the tree. (#262) Hopefully this fixes nondeterministic compiler
    crashes like #260.
  • Remove "provided" from the dependency on the Scala compiler again.
    This means that you do not need to add a dependency on the compiler if
    you are using refined's macros. (#268) See #256 for more
    details.

Updates

  • Update refined-pureconfig to PureConfig 0.6.0.
    Thanks to Viktor Lövgren!
    (#264)
  • Update refined-scalaz to Scalaz 7.2.10.
    (#258, #267)

Released on 2017-03-17

refined - 0.7.0

Published by fthomas over 7 years ago

Changes

  • Move the Eval predicate into the new refined-eval module
    because it requires a runtime dependency on the Scala compiler.
    Consequently the dependency on the Scala compiler in the core
    module is changed to a "provided" dependency.
    Thanks to Chris Hodapp!
    (#207, #251)

    Note that if you are using refined's macros, you need to add

    "org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
    

    now to your libraryDependencies.

Updates

Released on 2017-01-24

refined - 0.6.2

Published by fthomas almost 8 years ago

Changes

  • Add aliases for standard refined types like
    type PosInt = Int Refined Positive or
    type NegInt = Int Refined Negative to the
    eu.timepit.refined.types package. The date and time related type
    aliases haven been moved from util.time to the types.time package.
    (#236, #240, #249)
  • Add Cogen instance for any refined type to refined-scalacheck.
    (#244, #248)

Updates

Released on 2017-01-12