diff --git a/docs/_docs/reference/newtypes.md b/docs/_docs/reference/newtypes.md index fc786651..74d41fe7 100644 --- a/docs/_docs/reference/newtypes.md +++ b/docs/_docs/reference/newtypes.md @@ -94,3 +94,12 @@ val unsafeRuntime: Double = else throw new IllegalArgumentException("...") ``` +## New type with no constraint + +You can create a new type without restriction by using the [[Pure|io.github.iltotore.iron.constraint.any.Pure]] +constraint. [[Pure|io.github.iltotore.iron.constraint.any.Pure]] is an alias for +[[True|io.github.iltotore.iron.constraint.any.True]], a constraint that is always satisfied. + +```scala +type FirstName = String :| Pure +``` \ No newline at end of file diff --git a/main/src/io/github/iltotore/iron/constraint/any.scala b/main/src/io/github/iltotore/iron/constraint/any.scala index b388f55a..55b5321d 100644 --- a/main/src/io/github/iltotore/iron/constraint/any.scala +++ b/main/src/io/github/iltotore/iron/constraint/any.scala @@ -18,6 +18,12 @@ object any: */ final class True + /** + * Alias for [[True]]. Usually used for new types with no constraint. + * @see "Creating new types" reference. + */ + type Pure = True + /** * An always-invalid constraint. */