Skip to content

Releases: fthomas/refined

0.2.3

01 Sep 18:36
Compare
Choose a tag to compare

Changes

  • Add an implicit conversion from refined types to their base types. (#55)
  • Equal[N <: Nat] can now be used with all types that have a Numeric
    instance. This allows types like Double @@ Not[Equal[_0]].
  • Add an inference rule to go from Equal[N <: Nat] to any numeric predicate.
  • Remove deprecated refine, refineLit, and refineM.
  • Update to Scala.js 0.6.5.

0.2.2

18 Nov 19:16
Compare
Choose a tag to compare

Changes

  • Introduce the RefType type class which abstracts over shapeless.tag.@@
    and Refined and that allows 3rd-party types to be used as result type
    for refinements (e.g. scalaz.@@). RefType replaces the
    now removed internal.Wrapper type class. (#48, #53, #54)
  • Make the Refined constructor private (#52)

Released on 2015-08-17

0.2.1

18 Nov 19:18
Compare
Choose a tag to compare

Changes

  • Improve error messages of predicates created from partial functions.
    (This includes Regex, Url, Xml, and more.)
  • Add unwrap function to the internal.Wrapper type class.

New predicates

string

  • Xml: checks if a String is valid XML
  • XPath: checks if a String is a valid XPath expression

Released on 2015-08-06

0.2.0

18 Nov 19:19
Compare
Choose a tag to compare

Changes

  • Deprecate refine and refineLit in favor of the new refineT and
    refineMT (where T stands for tag/@@ and M for macro). In addition,
    there are two other variants of these functions, refineV and refineMV,
    that use the newly added Refined value class instead of @@. The advantages
    of Refined is that it can be used in combination with
    type aliases.
  • Add string utility functions to create statically checked regular expressions,
    URIs, URLs, and UUIDs. A detailed description of these functions can be found
    here. (#35, #38)
  • Lift the restriction to refine only literal values at compile-time if a
    Predicate is constant (i.e. it ignores its argument when calling isValid).
    Some examples of constant predicates are True or False or the newly added
    ConstructorNames and FieldNames predicates. Some examples of the last two
    predicates can be found here. (#26)
  • Enable tests in the Scala.js build. (#29)
  • Remove refine from Predicate since the purpose of Predicate is
    to check whether a value conforms to a type-level predicate. Refining
    the type of such value is a different concern. (#31)
  • Add inference rules for numeric singleton types to shapeless.Nat.

New predicates

generic

  • ConstructorNames[P]: checks if the constructor names of a sum type satisfy P
  • FieldNames[P]: checks if the field names of a product type satisfy P

string

  • Uuid: checks if a String is a valid UUID

Released on 2015-07-27

0.1.3

15 Jul 12:52
Compare
Choose a tag to compare

Changes

  • Update to shapeless 2.2.4.

New predicates

generic

  • Subtype[U]: witnesses that the type of a value is a subtype of U
  • Supertype[U]: witnesses that the type of a value is a supertype of U

0.1.2

18 Nov 19:23
Compare
Choose a tag to compare

Changes

  • Add refine function to the Predicate type class.
  • Add Predicate.fromPartial for creating a Predicate from a partial function.
  • Update to Scala 2.11.7 and Scala.js 0.6.4.

New predicates

string

  • Uri: checks if a String is a valid URI
  • Url: checks if a String is a valid URL

Released on 2015-07-06

0.1.1

18 Nov 19:24
Compare
Choose a tag to compare

Changes

  • Cross-build to Scala.js.
  • Updated to shapeless 2.2.3.

Released on 2015-06-27

0.1.0

18 Nov 19:29
Compare
Choose a tag to compare

Changes

  • Added inference rules to enable automatic conversions between different
    refined types (in the absent of any subtype relation). For example, a value
    of type Int @@ Greater[_5] can be safely converted to an Int @@ Positive,
    but the reverse is not true:

    scala> refineLit[Greater[_5]](10)
    res1: Int @@ Greater[_5] = 10
    
    scala> res1: Int @@ Positive
    res2: Int @@ Positive = 10
    
    scala> res2: Int @@ Greater[_5]
    <console>:42: error: invalid inference: Positive ==> Greater[_5]
                  res2: Int @@ Greater[_5]
                  ^

    Note that these conversions need to be enabled with an import:
    import eu.timepit.refined.implicits._

  • Added an implicit version of refineLit to the implicits object.
    This allows to write

    val a: Char @@ Digit = '4'

    instead of

    val a: Char @@ Digit = refineLit('4')
  • Made Predicate serializable.

  • Removed IsNull and NonNull predicates since they often caused ambiguous
    implicit errors and Scala has better means to handle null values.

  • Updated to shapeless 2.2.2. (#8, #13)

Bug fixes

  • refineLit always required a prior import of shapeless.tag.@@. (9f6d7d9)
  • Changed build to multi-project build so that tut-core is not added as
    dependency to refined. (#17)

New predicates

numeric

  • NonPositive: checks if a numeric value is zero or negative
  • NonNegative: checks if a numeric value is zero or positive

string

  • EndsWith[S]: checks if a String ends with the suffix S
  • Regex: checks if a String is a valid regular expression
  • StartsWith[S]: checks if a String starts with the prefix S

Released on 2015-06-20

0.0.3

18 Nov 19:30
Compare
Choose a tag to compare

Changes

  • Added Predicate instances for numeric predicates that take singleton
    types as arguments. For example refineLit[Less[W.-12.3.T]](-12.5)
    checks at compile time that -12.5 is less than -12.3.
  • refine and refineLit are now regular functions and not objects
    with an apply method.
  • Updated to shapeless 2.2.0.

Bug fixes

  • refineLit works now with predicates that contain singleton types.
    For example refineLit[MatchesRegex[W."[0-9]+".T](<string literal>)
    checks at compile-time if <string literal> matches the regular
    expression "[0-9]+". (#2)
  • Worked around a strange initialization bug in refineLit. (#3)

New predicates

boolean

  • Xor[A, B]: exclusive disjunction of the predicates A and B
  • OneOf[PS]: exclusive disjunction of all predicates in PS

char

  • LetterOrDigit: checks if a Char is a letter or digit

collection

  • Contains[U]: checks if a TraversableOnce contains a value equal to U
  • Head[P]: checks if the predicate P holds for the first element of
    a Traversable
  • Index[N, P]: checks if the predicate P holds for the element at
    index N of a sequence
  • Last[P]: checks if the predicate P holds for the last element of
    a Traversable

generic

  • IsNull: checks if a value is null
  • NonNull: checks if a value is not null

Released on 2015-05-31

0.0.2

18 Nov 19:31
Compare
Choose a tag to compare

Changes

  • Nicer syntax for refine and refineLit. The type that is refined does not
    need to be specified anymore. E.g. there is no need to specify Char in
    refineLit[AnyOf[Digit :: Letter :: Whitespace :: HNil]]('F').

New predicates

boolean

  • AllOf[PS]: conjunction of all predicates in PS
  • AnyOf[PS]: disjunction of all predicates in PS

char

  • Digit: checks if a Char is a digit
  • Letter: checks if a Char is a letter
  • Whitespace: checks if a Char is white space

collection

  • Count[PA, PC]: counts the number of elements in a TraversableOnce
    which satisfy the predicate PA and passes the result to the numeric
    predicate PC
  • MinSize[N]: checks if the size of a TraversableOnce is greater than
    or equal to N
  • MaxSize[N]: checks if the size of a TraversableOnce is less than
    or equal to N

generic

  • Equal[U]: checks if a value is equal to U

string

  • MatchesRegex[R]: checks if a String matches the regular expression R

Released on 2015-05-22