Did you know ... | Search Documentation: |
Pack logtalk -- logtalk-3.77.0/docs/_sources/type_0.rst.txt |
.. index:: type .. _type/0:
.. rst-class:: right
object
type
Type checking predicates. User extensible. New types can be defined by adding clauses for the type/1 and check/2 multifile predicates.
| Availability:
| logtalk_load(types(loader))
| Author: Paulo Moura | Version: 2:5:0 | Date: 2024-03-07
| Compilation flags:
| static, context_switching_calls, complements(restrict)
| Uses: | :ref:`list <list/0>`
| Remarks:
entity
, object
, protocol
, category
, entity_identifier
, object_identifier
, protocol_identifier
, category_identifier
, event
, predicate
.module
, module_identifier
, qualified_callable
.term
, var
, nonvar
, atomic
, atom
, number
, integer
, float
, compound
, callable
, ground
.non_quoted_atom
, non_empty_atom
, boolean
, character
, in_character
, char
, operator_specifier
, hex_char
.atom(CharSet)
, atom(CharSet,Length)
, non_empty_atom(CharSet)
, character(CharSet)
, in_character(CharSet)
, char(CharSet)
.positive_number
, negative_number
, non_positive_number
, non_negative_number
.positive_float
, negative_float
, non_positive_float
, non_negative_float, probability
.positive_integer
, negative_integer
, non_positive_integer
, non_negative_integer
, byte
, in_byte
, character_code
, in_character_code
, code
, operator_priority
, hex_code
.character_code(CharSet)
, in_character_code(CharSet)
, code(CharSet)
.list
, non_empty_list
, partial_list
, list_or_partial_list
, list(Type)
, list(Type,Length)
, list(Type,Min,Max)
, list(Type,Length,Min,Max)
, non_empty_list(Type)
, codes
, chars
.difference_list
, difference_list(Type)
.compound(Name,Types)
, predicate_indicator
, non_terminal_indicator
, predicate_or_non_terminal_indicator
, clause
, grammar_rule
, pair
, pair(KeyType,ValueType)
, cyclic
, acyclic
.stream
, stream_or_alias
, stream(Property)
, stream_or_alias(Property)
.Object::Closure
, between(Type,Lower,Upper)
, property(Type,LambdaExpression)
, one_of(Type,Set)
, var_or(Type)
, ground(Type)
, types(Types)
, constrain(Type,Closure)
, type
.predicate
notes: This type is used to check for an object public predicate specified as Object::Functor/Arity
.boolean
notes: The two value of this type are the atoms true
and false
.stream(Property)
and stream_or_alias(Property)
types, Property must be a valid stream property.order
notes: The three possible values of this type are the single character atoms <
, =
, and >
.character_code
notes: This type takes into account Unicode support by the backend compiler. When Unicode is supported, it distinguishes between BMP and full support. When Unicode is not supported, it assumes a byte representation for characters.Object::Closure
notes: Allows calling a public object predicate for type-checking. The predicate should provide valid/2 predicate semantics and assume called with a bound argument. The Closure
closure is extended with a single argument, the value to be checked.compound(Name,Types)
notes: This type verifies that a compound term have the given Name
and its arguments conform to Types
.between(Type, Lower, Upper)
notes: The type argument allows distinguishing between numbers and other types. It also allows choosing between mixed integer/float comparisons and strict float or integer comparisons. The term is type-checked before testing for interval membership.property(Type, Lambda)
notes: Verifies that Term
satisfies a property described using a lambda expression of the form [Parameter]>>Goal
. The lambda expression is applied in the context of user
. The term is type-checked before calling the goal.one_of(Type, Set)
notes: For checking if a given term is an element of a set. The set is represented using a list. The term is type-checked before testing for set membership.var_or(Type)
notes: Allows checking if a term is either a variable or a valid value of the given type.ground(Type)
notes: Allows checking if a term is ground and a valid value of the given type.types(Types)
notes: Allows checking if a term is a valid value for one of the types in a list of types.constrain(Type,Closure)
notes: Allows checking if a term is a valid value for the given type and satisfies the given closure.type
notes: Allows checking if a term is a valid type.qualified_callable
notes: Allows checking if a term is a possibly module-qualified callable term. When the term is qualified, it also checks that the qualification modules are type correct. When the term is not qualified, its semantics are the same as the callable type.var_or(Type)
. The sub-types of a meta-type can be enumerated by defining a clause for the meta_type/3 multifile predicate.ascii_identifier
, ascii_printable
, ascii_full
, byte
, unicode_bmp
, or unicode_full
) using the parameterizable types.
| Inherited public predicates:
| Â :ref:arbitrary/0::arbitrary/1
 :ref:arbitrary/0::arbitrary/2
 :ref:arbitrary/0::edge_case/2
 :ref:arbitrary/0::get_seed/1
 :ref:arbitrary/0::max_size/1
 :ref:mutations/0::mutation/3
 :ref:arbitrary/0::set_seed/1
 :ref:arbitrary/0::shrink/3
 :ref:arbitrary/0::shrink_sequence/3
 :ref:arbitrary/0::shrinker/1
Â
.. contents:: :local: :backlinks: top
.. index:: type/1 .. _type/0::type/1:
type/1 ^^^^^^^^^^
Table of defined types. A new type can be registered by defining a clause for this predicate and adding a clause for the check/2 multifile predicate.
| Compilation flags:
| static, multifile
| Template:
| type(Type)
| Mode and number of proofs:
| type(?callable)
- zero_or_more
.. index:: meta_type/3 .. _type/0::meta_type/3:
meta_type/3 ^^^^^^^^^^^^^^^
Table of defined meta-types. A registered type that is a meta-type can be described by defining a clause for this predicate to enumerate its sub-types and optional values in case of a single sub-type.
| Compilation flags:
| static, multifile
| Template:
| meta_type(MetaType,SubTypes,Values)
| Mode and number of proofs:
| meta_type(?callable,-list,-list)
- zero_or_more
.. index:: valid/2 .. _type/0::valid/2:
valid/2 ^^^^^^^^^^^
True if the given term is of the specified type. Fails otherwise.
| Compilation flags:
| static
| Template:
| valid(Type,Term)
| Mode and number of proofs:
| valid(@callable,@term)
- zero_or_one
.. index:: check/3 .. _type/0::check/3:
check/3 ^^^^^^^^^^^
True if the given term is of the specified type. Throws an error otherwise using the format error(Error, Context)
. For the possible values of Error
see the check/2 predicate.
| Compilation flags:
| static
| Template:
| check(Type,Term,Context)
| Mode and number of proofs:
| check(@callable,@term,@term)
- one_or_error
.. index:: check/2 .. _type/0::check/2:
check/2 ^^^^^^^^^^^
True if the given term is of the specified type. Throws an error otherwise. A new type can be added by defining a clause for this predicate and registering it by adding a clause for the type/1 multifile predicate.
| Compilation flags:
| static, multifile
| Template:
| check(Type,Term)
| Meta-predicate template:
| check(::,*)
| Mode and number of proofs:
| check(@callable,@term)
- one_or_error
| Exceptions:
| Term
is not bound as required:
| instantiation_error
| Term
is bound but not of the specified type:
| type_error(Type,Term)
| Term
is the of the correct type but not in the specified domain:
| domain_error(Domain,Term)
| Term
is the of the correct type and domain but the resource it represents does not exist:
| existence_error(Type,Term)
(no local declarations; see entity ancestors if any)
(no local declarations; see entity ancestors if any)
(none)
.. seealso::
:ref:`arbitrary <arbitrary/0>`, :ref:`os_types <os_types/0>`, :ref:`either <either/0>`, :ref:`maybe <maybe/0>`