Skip to content

v2.6.0

Latest
Compare
Choose a tag to compare
@Iltotore Iltotore released this 21 Jun 10:56
· 13 commits to main since this release

Introduction

This release adds new "all" variants introduced in 2.5.0 as well as compile-time UX enhancements.

Main changes

First-order variants for Cats and ZIO

iron-cats and iron-zio now include "all" variants for ValidatedNec/EitherNec/Nel... and Validation.

opaque type Username = String :| Alphanumeric
object Username extends RefinedTypeOps[String, Alphanumeric, Username]
//Success(List("CoolSkeleton95", "Alice"): List[String :| Alphanumeric])
List("CookSkeleton95", "Alice").refineAllValidation[Alphanumeric]

/*
Failure(NonEmptyChunk(
  InvalidValue("Il_totore", "Should be alphanumeric"),
  InvalidValue(" ", "Should be alphanumeric")
))
*/
List("Il_totore", "CoolSkeleton95", " ", "Alice").refineAllValidation[Alphanumeric]

//Success(List("CoolSkeleton95", "Alice"): List[Username])
Username.validationAll(List("CookSkeleton95", "Alice"))

(Scastie)

More useful compile-time errors

A reason is now given when an error fails at compile-time:

val y: Int = ??? //Runtime value
val x: Int :| Greater[10] = y
[error]    |-- Constraint Error --------------------------------------------------------
[error]    |Cannot refine value at compile-time because the predicate cannot be evaluated.
[error]    |This is likely because the condition or the input value isn't fully inlined.
[error]    |
[error]    |To test a constraint at runtime, use one of the `refine...` extension methods.
[error]    |
[error]    |Inlined input: y
[error]    |Inlined condition: (y.>(10.0): scala.Boolean)
[error]    |Message: Should be greater than 10
[error]    |Reason: Some arguments of `>` are not inlined:
[error]    |Arg 0:
[error]    |  Term not inlined: y
[error]    |----------------------------------------------------------------------------

Better colors for compile-time errors

Instead of aqua, compile-time errors use magenta which is more readable in Scastie than the former. Expressions are now highlighted:

Screenshot

image

Configurable compile-time errors

Compile-time errors can now be tweaked with two options:

  • -Diron.color to enable (true)/disable (false) compile-time messages colorations, including syntax highlighting
  • -Diron.shortMessages to display short summaries instead of full messages. Useful for Lens (such as Error Lens on VSCode or Inspection Lens on Intellij IDEA) users to have quick insights while coding.
Lens screenshot

In the following example, the flag -Diron.shortMessages=true was added to BSP arguments.

image

Adopters

The company Clever Cloud and the Tessela project are now listed on the README as adopters.

Contributors

Full Changelog: v2.5.0...v2.6.0