Package

zio

prelude

Permalink

package prelude

Visibility
  1. Public
  2. All

Type Members

  1. sealed trait Assertion[-A] extends AnyRef

    Permalink
  2. sealed trait AssertionError extends AnyRef

    Permalink
  3. trait Liftables extends AnyRef

    Permalink
    Annotations
    @silent( ... )
  4. trait QuotedAssertion[A] extends AnyRef

    Permalink
  5. final case class assertionLambdaQuote[A](f: (A) ⇒ Either[AssertionError, Unit]) extends Annotation with StaticAnnotation with Product with Serializable

    Permalink
  6. final case class assertionQuote[A](assertion: Assertion[A]) extends Annotation with StaticAnnotation with Product with Serializable

    Permalink
  7. final case class assertionString(string: String) extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

Value Members

  1. object Assertion

    Permalink

    An Assertion[A] is essentially a composable predicate from A => Boolean.

    An Assertion[A] is essentially a composable predicate from A => Boolean. They can be composed with standard Boolean operators of &&, || and !. This is primarily intended to be used with Newtype and Subtype, enhancing them with compile-time time validation.

    For example, if you'd like to validate that a particular Int is precisely 4 digits long, you can create the following refined Newtype. (Note that the syntax is slightly difference between Scala 2 and Scala 3).

    type Pin = Pin.Type
    object Pin extends Newtype[Int] {
      // Scala 2 Syntax
      def assertion =
        assert(Assertion.between(1000, 9999))
    
      // Scala 3 Syntax
      override inline def assertion =
        Assertion.between(1000, 9999)
    }
    
    // PowerOfTwo(1000) compiles
    // PowerOfTwo(5412) compiles
    // PowerOfTwo(34567) fails with "34567 did not satisfy between(1000, 9999)"
    // PowerOfTwo(234) fails with "123 did not satisfy between(1000, 9999)"
  2. object AssertionError

    Permalink
  3. package macros

    Permalink

Ungrouped