RuntimeConstraint

io.github.iltotore.iron.RuntimeConstraint
See theRuntimeConstraint companion object
final class RuntimeConstraint[A, C](_test: A => Boolean, val message: String)

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 Object
trait Matchable
class Any

Members list

Value members

Concrete methods

inline def test(value: A): Boolean

Attributes

Source
RuntimeConstraint.scala

Concrete fields

val message: String

Attributes

Source
RuntimeConstraint.scala