Tell the user that Culprit is not of the expected ValidType.
This error is closely related to domain_error/2
because the notion of types is not really set in stone in Prolog. We
introduce the difference using a simple example.
Suppose an argument must be a non-negative integer. If the actual
argument is not an integer, this is a type_error. If it is a
negative integer, it is a domain_error.
Typical borderline cases are predicates accepting a compound term,
True if Term satisfies the type constraints for Type.
Defined types are
point(X,Y). One could argue that the basic type is a
compound-term and any other compound term is a domain error. Most Prolog
programmers consider each compound as a type and would consider a
compound that is not
point(_,_) a type_error.
Most of these types are defined by an arity-1 built-in predicate of
the same name. Below is a brief definition of the other types.
|acyclic||Acyclic term (tree); see acyclic_term/1 |
|any||any term |
|Integer [IntL..IntU] |
|boolean||One of |
|char||Atom of length 1 |
|chars||Proper list of 1-character atoms |
|code||Representation Unicode code point |
|codes||Proper list of Unicode character codes |
|constant||Same as |
|cyclic||Cyclic term (rational tree); see cyclic_term/1 |
|dict||A dictionary term; see is_dict/1 |
|encoding||Valid name for a character encoding; see current_encoding/1 |
|list||A (non-open) list; see is_list/1 |
|negative_integer||Integer < 0 |
|Ground term that is member of L |
|pair||Key-Value pair |
|positive_integer||Integer > 0 |
|proper_list||Same as list |
|Proper list with elements of Type |
|list_or_partial_list||A list or an open list (ending in a
variable); see is_list_or_partial_list/1 |
|stream||A stream name or valid stream handle; see is_stream/1 |
|symbol||Same as |
|text||One of |
|type||Term is a valid type specification |
Note: The Windows version can only represent Unicode code points up
^16-1. Higher values cause a representation error on
most text handling predicates.
- instantiation_error if Term is insufficiently instantiated
type_error(Type, Term) if Term is not of Type.