.. index:: expected
.. _expected/0:

.. rst-class:: right

**object**

``expected``
============

Constructors for expected term references. A reference contains either an expected term or an unexpected term. References should be regarded as opaque terms and always used with the ``expected/1`` object by passing the reference as a parameter.

| **Author:** Paulo Moura
| **Version:** 1.2
| **Date:** 2019/1/23

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Provides:**
|    :ref:`type::type/1 <type/0::type/1>`
|    :ref:`type::check/2 <type/0::check/2>`

| **Remarks:**


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

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. raw:: html

   <div id="of_unexpected/2"> </div>

.. index:: of_unexpected/2
.. _expected/0::of_unexpected/2:

``of_unexpected/2``
^^^^^^^^^^^^^^^^^^^

Constructs a reference from an unexpected term.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``of_unexpected(Unexpected,Reference)``
| **Mode and number of proofs:**
|    ``of_unexpected(@term,--nonvar)`` - ``one``


------------

.. raw:: html

   <div id="of_expected/2"> </div>

.. index:: of_expected/2
.. _expected/0::of_expected/2:

``of_expected/2``
^^^^^^^^^^^^^^^^^

Constructs a reference from an expected term.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``of_expected(Expected,Reference)``
| **Mode and number of proofs:**
|    ``of_expected(@term,--nonvar)`` - ``one``


------------

.. raw:: html

   <div id="from_goal/4"> </div>

.. index:: from_goal/4
.. _expected/0::from_goal/4:

``from_goal/4``
^^^^^^^^^^^^^^^

Constructs a reference by calling ``Goal`` that binds and holds ``Expected`` on success. Otherwise returns a reference with the unexpected goal error or failure represented by the ``Failure`` argument.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``from_goal(Goal,Expected,Failure,Reference)``
| **Meta-predicate template:**
|    ``from_goal(0,*,*,*)``
| **Mode and number of proofs:**
|    ``from_goal(+callable,--term,@term,--nonvar)`` - ``one``


------------

.. raw:: html

   <div id="from_goal/3"> </div>

.. index:: from_goal/3
.. _expected/0::from_goal/3:

``from_goal/3``
^^^^^^^^^^^^^^^

Constructs a reference by calling ``Goal`` that binds and uses ``Expected`` on success. Otherwise returns a reference with the unexpected goal error or failure represented by the atom ``fail``.

| **Compilation flags:**
|    ``static``

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


------------

Protected predicates
--------------------

(see entity ancestors)

Private predicates
------------------

(see entity ancestors)

Operators
---------

(none)

.. seealso::

   :ref:`expected(Reference) <expected/1>`, :ref:`type <type/0>`

