io.github.iltotore.iron

Members list

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.

Type parameters

A

the type of the value to test.

C

the constraint associated with this implementation.

Attributes

Companion
object
Source
Constraint.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
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]
class UnionConstraint[A, C]
Show all
object Constraint

Attributes

Companion
trait
Source
Constraint.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Constraint.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).

Type parameters

C1

the assumed constraint.

C2

the constraint implied by C1.

Attributes

Companion
object
Source
Implication.scala
Supertypes
class Object
trait Matchable
class Any
object Implication

Attributes

Companion
class
Source
Implication.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object IronType

Attributes

Source
package.scala
Supertypes
class Object
trait Matchable
class Any
Self type
IronType.type
trait MapLogic[F[_]]

A typeclass providing a map method. Mainly used to abstract over Cats and ZIO Prelude.

A typeclass providing a map method. Mainly used to abstract over Cats and ZIO Prelude.

Type parameters

F

the wrapper type

Attributes

Companion
object
Source
MapLogic.scala
Supertypes
class Object
trait Matchable
class Any
object MapLogic

Attributes

Companion
trait
Source
MapLogic.scala
Supertypes
class Object
trait Matchable
class Any
Self type
MapLogic.type
trait NegShift[A]

Attributes

Companion
object
Source
NegShift.scala
Supertypes
class Object
trait Matchable
class Any
object NegShift

Attributes

Companion
trait
Source
NegShift.scala
Supertypes
class Object
trait Matchable
class Any
Self type
NegShift.type
trait PosShift[A]

Attributes

Companion
object
Source
PosShift.scala
Supertypes
class Object
trait Matchable
class Any
object PosShift

Attributes

Companion
trait
Source
PosShift.scala
Supertypes
class Object
trait Matchable
class Any
Self type
PosShift.type
trait RefinedTypeOps[A, C, T](using _rtc: RuntimeConstraint[A, C])

Utility trait for new types' companion object.

Utility trait for new types' companion object.

Type parameters

A

the base type of the new type

C

the constraint type of the new type

T

the new type (equivalent to A :| C if T is a transparent alias)

Attributes

Companion
object
Source
RefinedTypeOps.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Source
RefinedTypeOps.scala
Supertypes
class Object
trait Matchable
class Any
Self type
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.

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

Attributes

Companion
class
Source
RuntimeConstraint.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object cats

Attributes

Source
cats.scala
Supertypes
class Object
trait Matchable
class Any
Self type
cats.type
object circe

Implicit Encoders and Decoders for refined types.

Implicit Encoders and Decoders for refined types.

Attributes

Source
circe.scala
Supertypes
class Object
trait Matchable
class Any
Self type
circe.type
object ciris

Attributes

Source
ciris.scala
Supertypes
class Object
trait Matchable
class Any
Self type
ciris.type
object compileTime

Methods and types to ease compile-time operations.

Methods and types to ease compile-time operations.

Attributes

Source
compileTime.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object decline

Implicit Argument instances for refined types.

Implicit Argument instances for refined types.

Attributes

Source
decline.scala
Supertypes
class Object
trait Matchable
class Any
Self type
decline.type
object doobie

Implicit Metas, Puts and Gets for refined types.

Implicit Metas, Puts and Gets for refined types.

Attributes

Source
doobie.scala
Supertypes
class Object
trait Matchable
class Any
Self type
doobie.type
object jsoniter

Attributes

Source
jsoniter.scala
Supertypes
class Object
trait Matchable
class Any
Self type
jsoniter.type
object skunk

Attributes

Source
skunk.scala
Supertypes
class Object
trait Matchable
class Any
Self type
skunk.type
object upickle

Implicit Readers and Writers for refined types using uPickle.

Implicit Readers and Writers for refined types using uPickle.

Attributes

Source
upickle.scala
Supertypes
class Object
trait Matchable
class Any
Self type
upickle.type
object zio

Attributes

Source
zio.scala
Supertypes
class Object
trait Matchable
class Any
Self type
zio.type
object zioJson

Attributes

Source
zioJson.scala
Supertypes
class Object
trait Matchable
class Any
Self type
zioJson.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

Source
package.scala
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

Source
Implication.scala
opaque type IronType[A, C]

An Iron type (refined).

An Iron type (refined).

Type parameters

A

the underlying type.

C

the predicate/constraint guarding this type.

Attributes

Source
package.scala

Extensions

Extensions

extension [A](value: A)
inline def assume[B]: IronType[A, B]

Refine the given value, assuming the constraint holds.

Refine the given value, assuming the constraint holds.

Attributes

Returns

a constrained value, without performing constraint checks.

See also

assumeAll, autoRefine, refineUnsafe.

Source
package.scala
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.

Value parameters

constraint

the constraint to test with the value to refine.

Attributes

Returns

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

See also

autoRefine, refineUnsafe, refineOption.

Source
package.scala
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.

Value parameters

constraint

the constraint to test with the value to refine.

Attributes

Returns

an Option containing this value as IronType or None.

See also

autoRefine, refineUnsafe, refineEither.

Source
package.scala
extension [A, C1](value: IronType[A, C1])
inline def assumeFurther[C2]: IronType[A, C1 & C2]

Refine the given value again, assuming the constraint holds.

Refine the given value again, assuming the constraint holds.

Attributes

Returns

a constrained value, without performing constraint checks.

See also

assume, assumeAllFurther.

Source
conversion.scala
inline def refineFurtherEither[C2](using inline constraint: Constraint[A, C2]): Either[String, IronType[A, C1 & C2]]

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

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

Value parameters

constraint

the new constraint to test.

Attributes

Returns

a Right containing this value refined with C1 & C2 or a Left containing the constraint message.

See also
Source
conversion.scala
inline def refineFurtherOption[C2](using inline constraint: Constraint[A, C2]): Option[IronType[A, C1 & C2]]

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

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

Value parameters

constraint

the new constraint to test.

Attributes

Returns

a Option containing this value refined with C1 & C2 or None.

See also
Source
conversion.scala
extension [A, C1, C2](value: IronType[IronType[A, C1], C2])
inline def compose: IronType[A, C1 & C2]

Transform A :| C1 :| C2 to A :| (C1 & C2)

Transform A :| C1 :| C2 to A :| (C1 & C2)

Attributes

Source
conversion.scala
extension [A, C1, C2](value: IronType[A, C1 & C2])
inline def decompose: IronType[IronType[A, C1], C2]

Transform A :| (C1 & C2) to A :| C1 :| C2

Transform A :| (C1 & C2) to A :| C1 :| C2

Attributes

Source
conversion.scala
extension [F[_], A](wrapper: F[A])
inline def assumeAll[B]: F[IronType[A, B]]

Refine the contained value(s), assuming the constraint holds.

Refine the contained value(s), assuming the constraint holds.

Attributes

Returns

constrained values, without performing constraint checks.

See also

assume, autoRefine, refineUnsafe.

Source
package.scala
inline def refineAllEither[B](using mapLogic: MapLogic[F], inline constraint: Constraint[A, B]): Either[String, F[IronType[A, B]]]

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

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

Value parameters

constraint

the constraint to test with the value to refine.

Attributes

Returns

a Right containing the given values as IronType or a Left containing the constraint message.

See also
Source
package.scala
inline def refineAllOption[B](using mapLogic: MapLogic[F], inline constraint: Constraint[A, B]): Option[F[IronType[A, B]]]

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

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

Value parameters

constraint

the constraint to test with the value to refine.

Attributes

Returns

a Some containing the given values as IronType or None.

See also
Source
package.scala
extension [F[_], A, C1](wrapper: F[IronType[A, C1]])
inline def assumeAllFurther[C2]: F[IronType[A, C1 & C2]]

Refine the given value(s) again, assuming the constraint holds.

Refine the given value(s) again, assuming the constraint holds.

Attributes

Returns

the constrained values, without performing constraint checks.

See also

assume, assumeFurther.

Source
conversion.scala
inline def refineAllFurtherEither[C2](using mapLogic: MapLogic[F], inline constraint: Constraint[A, C2]): Either[String, F[IronType[A, C1 & C2]]]

Refine the given value(s) again at runtime, resulting in an Either.

Refine the given value(s) again at runtime, resulting in an Either.

Value parameters

constraint

the new constraint to test.

Attributes

Returns

a Right containing the given values refined with C1 & C2 or a Left containing the constraint message.

See also
Source
conversion.scala
inline def refineAllFurtherOption[C2](using mapLogic: MapLogic[F], inline constraint: Constraint[A, C2]): Option[F[IronType[A, C1 & C2]]]

Refine the given value(s) again at runtime, resulting in an Option.

Refine the given value(s) again at runtime, resulting in an Option.

Value parameters

constraint

the new constraint to test.

Attributes

Returns

a Option containing the given values refined with C1 & C2 or None.

See also
Source
conversion.scala
inline def refineAllFurtherUnsafe[C2](using mapLogic: MapLogic[F], inline constraint: Constraint[A, C2]): F[IronType[A, C1 & C2]]

Refine the given value(s) again at runtime.

Refine the given value(s) again at runtime.

Value parameters

constraint

the new constraint to test.

Attributes

Returns

the given values refined with C1 & C2.

Throws
IllegalArgumentException

if the constraint is not satisfied.

See also

refineUnsafe, refineFurtherUnsafe.

Source
conversion.scala

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.

Type parameters

A

the refined type.

C1

the original constraint.

C2

the target constraint.

Value parameters

`C1

==> C2the evidence that the original constraintC1impliesC2`.

value

the refined to value to cast.

Attributes

Returns

the given value constrained by C2.

Source
conversion.scala
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.

Type parameters

A

the refined type.

C1

the original constraint.

C2

the target constraint.

I

the iterable type.

Value parameters

`C1

==> C2the evidence thatC1impliesC2`.

iterable

the iterable to factorize.

Attributes

Returns

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

See also
Source
conversion.scala
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.

Type parameters

A

the refined type.

C1

the original constraint.

C2

the target constraint.

I

the iterable type.

Value parameters

`C1

==> C2the evidence thatC1impliesC2`.

iterable

the iterable to factorize.

Attributes

Returns

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

See also
Source
conversion.scala
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.

Type parameters

A

the refined type.

C

the constraint applied to the type.

Value parameters

constraint

the implementation of C to check.

value

the value to refine.

Attributes

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.

Source
conversion.scala

Exports

Defined exports

final type ! = !
Exported from any$

Attributes

Source
package.scala
final val DescribedAs: DescribedAs.type
Exported from any
final type DescribedAs = [C, V <: String] =>> DescribedAs[C, V]
Exported from any$

Attributes

Source
package.scala
final val False: False.type
Exported from any
final type False = False
Exported from any$

Attributes

Source
package.scala
final type In = [V <: NonEmptyTuple] =>> In[V]
Exported from any$

Attributes

Source
package.scala
final val Not: Not.type
Exported from any
final type Not = Not
Exported from any$

Attributes

Source
package.scala
final type Pure = Pure
Exported from any$

Attributes

Source
package.scala
final val StrictEqual: StrictEqual.type
Exported from any
final type StrictEqual = StrictEqual
Exported from any$

Attributes

Source
package.scala
final val True: True.type
Exported from any
final type True = True
Exported from any$

Attributes

Source
package.scala
final val Xor: Xor.type
Exported from any
final type Xor = Xor
Exported from any$

Attributes

Source
package.scala