object

validated

Types and predicates for type-checking and handling lists of validation terms. Inspired by Scala Cats and Kotlin Arrow.

Availability:
logtalk_load(validations(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-02-22
Compilation flags:
static, context_switching_calls
Remarks:
  • Type-checking support: Defines a validated(ValueType, ErrorType) type for checking validation terms where the value and error terms must be of the given types.

  • QuickCheck support: Defines clauses for the type::arbitrary/1-2, arbitrary::shrinker/1, arbitrary::shrink/3, and arbitrary::edge_case/2 predicates to allow generating random values for the validated(ValueType, ErrorType) type.

Inherited public predicates:
(none)

Public predicates

valids/2

Returns the values stored in validation terms that hold valid values.

Compilation flags:
static
Template:
valids(Validations,Values)
Mode and number of proofs:
valids(+list(validation),-list) - one

invalids/2

Returns a flattened list with all errors stored in invalid validation terms.

Compilation flags:
static
Template:
invalids(Validations,Errors)
Mode and number of proofs:
invalids(+list(validation),-list) - one

partition/3

Retrieves and partitions valid values and flattened accumulated errors from validation terms.

Compilation flags:
static
Template:
partition(Validations,Values,Errors)
Mode and number of proofs:
partition(+list(validation),-list,-list) - one

map/3

Applies a closure to each list element to generate validation terms and returns a pair Values-Errors accumulating all valid values and all errors in one pass.

Compilation flags:
static
Template:
map(Closure,Terms,ValuesErrors)
Meta-predicate template:
map(2,*,*)
Mode and number of proofs:
map(+callable,+list,--compound) - one

map/4

Applies a closure to each list element to generate validation terms and returns valid values and accumulated errors in one pass.

Compilation flags:
static
Template:
map(Closure,Terms,Values,Errors)
Meta-predicate template:
map(2,*,*,*)
Mode and number of proofs:
map(+callable,+list,-list,-list) - one

sequence/2

Sequences a list of validation terms into a single validation term, accumulating all errors.

Compilation flags:
static
Template:
sequence(Validations,Validation)
Mode and number of proofs:
sequence(+list(validation),--nonvar) - one

traverse/3

Applies a closure to each list element to generate validation terms and then sequences them, accumulating all errors.

Compilation flags:
static
Template:
traverse(Closure,Terms,Validation)
Meta-predicate template:
traverse(2,*,*)
Mode and number of proofs:
traverse(+callable,+list,--nonvar) - one

Protected predicates

(no local declarations; see entity ancestors if any)

Private predicates

(no local declarations; see entity ancestors if any)

Operators

(none)