-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2d9ca8
commit e0e0bdd
Showing
4 changed files
with
19 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package io.github.iltotore.iron | ||
|
||
type RuntimeConstraint[T] = T match | ||
case IronType[a, c] => RuntimeConstraint.Impl[a, c, T] | ||
final class RuntimeConstraint[A, T](_test: A => Boolean, val message: String): | ||
inline def test(value: A): Boolean = _test(value) | ||
|
||
object RuntimeConstraint: | ||
final class Impl[A, C, T](_test: A => Boolean, val message: String): | ||
inline def test(value: A): Boolean = _test(value) | ||
|
||
inline given derived[A, C](using inline c: Constraint[A, C]): RuntimeConstraint[A :| C] = | ||
new Impl[A, C, A :| C](c.test(_), c.message) | ||
inline def derived[A, C](using inline c: Constraint[A, C]): RuntimeConstraint[A, A :| C] = | ||
new RuntimeConstraint[A, A :| C](c.test(_), c.message) | ||
|
||
final class AutoDerived[A, T](val inner: RuntimeConstraint[A, T]) | ||
object AutoDerived: | ||
inline given derived[A, C](using inline c: Constraint[A, C]): AutoDerived[A, A :| C] = | ||
new AutoDerived[A, A :| C](RuntimeConstraint.derived[A, C]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters