Type: Violation

class core.check.Violation
type Violation = Tag(String, Any)
               | Equality(Any, Any)
               | Identity(Any, Any)
               | Any(Array(Any))
               | All(Array(Any))

implements
  Equality, Extractor, Reflect, Cata, Semigroup, ToString

Represents a violation of an interface’s constraint.

Combining

#concat()

Violation.prototype.concat(aViolation)
Returns:A Violation with the contents combined.
@Violation => Violation → Boolean

Combines the contents of two Violations.

Comparison and testing

#isTag

Violation.prototype.isTag
@Violation => Boolean

true is the Violation has a Tag tag.

#isEquality

Violation.prototype.isEquality
@Violation => Boolean

true is the Violation has an Equality tag.

#isIdentity

Violation.prototype.isIdentity
@Violation => Boolean

true is the Violation has an Identity tag.

#isAny

Violation.prototype.isAny
@Violation => Boolean

true is the Violation has an Any tag.

#isAll

Violation.prototype.isAll
@Violation => Boolean

true is the Violation has an All tag.

#equals()

Violation.prototype.equals(aViolation)
Returns:true if both Violations have the same contents (by reference equality).
@Violation => Violation → Boolean

Converting

#toString()

Violation.prototype.toString()
Returns:A textual representation of the Violation.
@Violation => Violation → Boolean

Transforming

#cata()

Violation.prototype.cata(aPattern)
Returns:The result of applying the right transformation to the Violation.
@Violation => { r | Pattern } → β
where type Pattern {
  Tag: (String, Any) → β,
  Equality: (Any, Any) → β,
  Identity: (Any, Any) → β,
  Any: Array(Any) → β,
  All: Array(Any) → β
}

Provides a crude form of pattern matching over the Violation ADT. Since Violation also implements the Extractor interface, you may choose to use the Sparkler Sweet.js macro instead for a more powerful form of pattern matching.