object

# `expected`

Constructors for expected terms. An expected term contains either a value or an error. Expected terms should be regarded as opaque terms and always used with the `expected/1` object by passing the expected term as a parameter.

Author: Paulo Moura
Version: 1.5
Date: 2019/11/26
Compilation flags:
`static, context_switching_calls`
Provides:
type::type/1
type::check/2
Remarks:

> - Type-checking support: This object also defines a type `expected` for use with the `type` library object.

Inherited public predicates:
(none)

- Public predicates

  - `of_unexpected/2`

  - `of_expected/2`

  - `from_goal/4`

  - `from_goal/3`

  - `from_goal/2`

- Protected predicates

- Private predicates

- Operators

## Public predicates

### `of_unexpected/2`

Constructs an expected term from an error that represent that the expected value is missing.

Compilation flags:
`static`
Template:
`of_unexpected(Error,Expected)`
Mode and number of proofs:
`of_unexpected(@term,--nonvar)` - `one`

### `of_expected/2`

Constructs an expected term from an expected value.

Compilation flags:
`static`
Template:
`of_expected(Value,Expected)`
Mode and number of proofs:
`of_expected(@term,--nonvar)` - `one`

### `from_goal/4`

Constructs an expected term holding a value bound by calling the given goal. Otherwise returns a reference with the unexpected goal error or failure represented by the `Error` argument.

Compilation flags:
`static`
Template:
`from_goal(Goal,Value,Error,Expected)`
Meta-predicate template:
`from_goal(0,*,*,*)`
Mode and number of proofs:
`from_goal(+callable,--term,@term,--nonvar)` - `one`

### `from_goal/3`

Constructs an expected term holding a value bound by calling the given goal. Otherwise returns an expected term with the unexpected goal error or, in case of closure goal, the atom `fail`.

Compilation flags:
`static`
Template:
`from_goal(Goal,Value,Expected)`
Meta-predicate template:
`from_goal(0,*,*)`
Mode and number of proofs:
`from_goal(+callable,--term,--nonvar)` - `one`

### `from_goal/2`

Constructs an expected term holding a value bound by calling the given closure. Otherwise returns an expected term holding the unexpected closure error or, in case of closure failure, the atom `fail`.

Compilation flags:
`static`
Template:
`from_goal(Closure,Expected)`
Meta-predicate template:
`from_goal(1,*)`
Mode and number of proofs:
`from_goal(+callable,--nonvar)` - `one`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)

See also

expected(Expected), type