io.github.iltotore.iron

Members list

Concise view

Type members

Classlikes

trait Constraint[A, C]

A typeclass representing the implementation of a constraint of a certain type of value.

A typeclass representing the implementation of a constraint of a certain type of value.

Attributes

A

the type of the value to test.

C

the constraint associated with this implementation.

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class UnionConstraint[A, C]
class DescribedAsConstraint[A, C, Impl, V]
class NotConstraint[A, C, Impl]
class XorConstraint[A, C1, C2, Impl1, Impl2]
class ExistsIterable[A, I, C, Impl]
class ExistsString[C, Impl]
class ForAllIterable[A, I, C, Impl]
class ForAllString[C, Impl]
class HeadIterable[A, I, C, Impl]
class HeadString[C, Impl]
class InitIterable[A, I, C, Impl]
class InitString[C, Impl]
class LastIterable[A, I, C, Impl]
class LastString[C, Impl]
class LengthIterable[I, C, Impl]
class LengthString[C, Impl]
class TailIterable[A, I, C, Impl]
class TailString[C, Impl]
object Constraint

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
final class Implication[C1, C2]

An algebraic implication between two constraints (e.g transitivity for constraint.numeric.Greater).

An algebraic implication between two constraints (e.g transitivity for constraint.numeric.Greater).

Attributes

C1

the assumed constraint.

C2

the constraint implied by C1.

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
object IronType

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Methods and types to ease compile-time operations.

Methods and types to ease compile-time operations.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Types

type :|[A, C] = IronType[A, C]

Alias for IronType. Similar to the mathematical symbol | in e.g {x in R | x > 0}.

Alias for IronType. Similar to the mathematical symbol | in e.g {x in R | x > 0}.

Attributes

type ==>[C1, C2] = Implication[C1, C2]

Alias for Implication. Similar to the mathematical implication symbol, often represented by an arrow.

Alias for Implication. Similar to the mathematical implication symbol, often represented by an arrow.

Attributes

opaque type IronType[A, C]

An Iron type (refined).

An Iron type (refined).

Attributes

A

the underlying type.

C

the predicate/constraint guarding this type.

Extensions

Extensions

extension [A](value: A)
inline def refine[B](using inline constraint: Constraint[A, B]): IronType[A, B]

Refine the given value at runtime.

Refine the given value at runtime.

Attributes

constraint

the constraint to test with the value to refine.

Returns:

this value as IronType.

Throws:
an

IllegalArgumentException if the constraint is not satisfied.

See also:
inline def refineEither[B](using inline constraint: Constraint[A, B]): Either[String, IronType[A, B]]

Refine the given value at runtime, resulting in an Either.

Refine the given value at runtime, resulting in an Either.

Attributes

constraint

the constraint to test with the value to refine.

Returns:

a Right containing this value as IronType or a Left containing the constraint message.

See also:
inline def refineOption[B](using inline constraint: Constraint[A, B]): Option[IronType[A, B]]

Refine the given value at runtime, resulting in an Option.

Refine the given value at runtime, resulting in an Option.

Attributes

constraint

the constraint to test with the value to refine.

Returns:

an Option containing this value as IronType or None.

See also:

Implicits

Implicits

implicit inline def autoCastIron[A, C1, C2](inline value: IronType[A, C1])(using Implication[C1, C2]): IronType[A, C2]

Implicitly cast a constrained value to another if verified.

Implicitly cast a constrained value to another if verified.

Attributes

A

the refined type.

C1

the original constraint.

C2

the target constraint.

`C1

==> C2the evidence that the original constraintC1impliesC2`.

value

the refined to value to cast.

Returns:

the given value constrained by C2.

implicit inline def autoDistribute[A, I <: (Iterable), C1, C2](inline iterable: IronType[I[A], ForAll[C1]])(using Implication[C1, C2]): I[IronType[A, C2]]

Implicitly cast an iterable constrained by ForAll[C1] into an iterable of elements constrained by C2 if C1 implies C2.

Implicitly cast an iterable constrained by ForAll[C1] into an iterable of elements constrained by C2 if C1 implies C2.

Attributes

A

the refined type.

C1

the original constraint.

C2

the target constraint.

I

the iterable type.

`C1

==> C2the evidence thatC1impliesC2`.

iterable

the iterable to factorize.

Returns:

the given value as instance of I[A :| C2].

See also:
implicit inline def autoFactorize[A, I <: (Iterable), C1, C2](inline iterable: I[IronType[A, C1]])(using Implication[C1, C2]): IronType[I[A], ForAll[C2]]

Implicitly cast an iterable of elements constrained by C1 into an iterable constrained by ForAll[C2] if C1 implies C2.

Implicitly cast an iterable of elements constrained by C1 into an iterable constrained by ForAll[C2] if C1 implies C2.

Attributes

A

the refined type.

C1

the original constraint.

C2

the target constraint.

I

the iterable type.

`C1

==> C2the evidence thatC1impliesC2`.

iterable

the iterable to factorize.

Returns:

the given value as instance of I[A] :| ForAll[C2].

See also:
implicit inline def autoRefine[A, C](inline value: A)(using inline constraint: Constraint[A, C]): IronType[A, C]

Implicitly refine at compile-time the given value.

Implicitly refine at compile-time the given value.

Attributes

A

the refined type.

C

the constraint applied to the type.

constraint

the implementation of C to check.

value

the value to refine.

Returns:

the given value typed as IronType

Note:

This method ensures that the value satisfies the constraint. If it doesn't or isn't evaluable at compile-time, the compilation is aborted.

Exports

Defined exports

final type ! = !
Exported from any$
final val DescribedAs: DescribedAs.type
Exported from any
final type DescribedAs = [C, V <: String] =>> DescribedAs[C, V]
Exported from any$
final val False: False.type
Exported from any
final type False = False
Exported from any$
final val Not: Not.type
Exported from any
final type Not = Not
Exported from any$
final val StrictEqual: StrictEqual.type
Exported from any
Exported from any$
final val True: True.type
Exported from any
final type True = True
Exported from any$
final val Xor: Xor.type
Exported from any
final type Xor = Xor
Exported from any$