Packages

trait Proposition[+E, -A] extends AnyRef

A data type for lazy consistency checks on a data structure.

A Proposition wraps a function that checks a proposition of a logical statement over a type. Combinators like leftMap, contramap, &&, ||, and not, can be used to easily create more complex checks.

val a = Proposition[String, Int](x => if(x > 10) False("age should be less than 10") else True)
//a: purity.Proposition[String,Int] = Proposition

a.check(21)
//res0: purity.Truth[String] = False(NonEmptyList(age should be less than 10))

a.check(9)
//res1: purity.Truth[String] = True

val b = Proposition[String, String](x => if(x.length > 2) False("name code should be less than 3") else True)
//b: purity.Proposition[String,String] = Proposition

val c = a.contramap[User](_.age) && b.contramap[User](_.name)
//c: purity.Proposition[String,User] = Proposition

c.check(User("FAF", 21))
//res3: purity.Truth[String] = False(NonEmptyList(age should be less than 10, name code should be less than 3))
E

type of the failure in case of an False result.

A

type to be checked for consistency.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Proposition
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def check(a: A): Truth[E]

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def &&[EE >: E, AA <: A](g: Proposition[EE, AA]): Proposition[EE, AA]
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. def contramap[B](f: (B) ⇒ A): Proposition[E, B]
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. def leftMap[E2](f: (E) ⇒ E2): Proposition[E2, A]
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def not[EE >: E](e: EE): Proposition[EE, A]
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. def optional: Proposition[E, Option[A]]
  20. def required[EE >: E](e: EE): Proposition[EE, Option[A]]
  21. def script[F[+_], E2](dsl: ScriptDsl[F])(a: A)(implicit ev: Applicative[F]): Independent[NonEmptyList[E], Unit]
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    Proposition → AnyRef → Any
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  27. def ||[EE >: E, AA <: A](g: Proposition[EE, AA]): Proposition[EE, AA]

Inherited from AnyRef

Inherited from Any

Ungrouped