Skip to content

Commit

Permalink
feat: Add Pure alias for True (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore authored Jun 30, 2023
1 parent 022d3f4 commit da8629d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/_docs/reference/newtypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
6 changes: 6 additions & 0 deletions main/src/io/github/iltotore/iron/constraint/any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit da8629d

Please sign in to comment.