io.github.iltotore.iron.RuntimeConstraint
See theRuntimeConstraint companion object
A RuntimeConstraint is similar to a Constraint with the difference that it can be used in non-inlined methods.
This allows refinement of values in polymorphic methods / givens without the use of inline
. e.g., the code below would fail to compile if Constraint was used instead.
def foo[A, C](value: A)(using c: RuntimeConstraint[A, C]): Either[String, A :| C] =
if c.test(value) then Right(value.assume[C]) else Left(c.message)
In cases that one does not exist in scope, one will be automatically derived from a Constraint.
Attributes
- Companion
- object
- Source
- RuntimeConstraint.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
In this article