Introducing Iron: type-level assertions for Scala

Hello everyone!

This is an introduction to Iron, a type constraint system for Scala. It allows you to create either-based assertions at type level.

Here is a small example using iron-numeric:

def log(x: Double ==> Greater[0d]): Refined[Double] =

val x = -1d
val y = 1d
log(x) //Left(IllegalValueError(0d, "value should be greater than the specified value"))
log(y) //Right(1d)

Iron can also optimize and evaluate constraints at compile-time in some cases:

log(-1d) //Compile-time error
log(1d) //Replaced at compile time by `Right(1d)`

Iron also has modules for other kind of data (string, numeric, iterable…) and for some projects (cats, circe…)

More information on the project repository: GitHub - Iltotore/iron: Hardened type constraints for Scala

A small example of a REST API using Iron & Cats is available here.

I already wrote a post about my project in r/scala when 0.1.0 was released and I had many good reviews. Now, Iron v1.1 is out and I’m open for any suggestion here and in the Issues section. :slightly_smiling_face: