mavis.pl -- Optional type declarations

Declare optional types which are checked during development time. See pack documentation for more information.

the(+Type:type, ?Value) is det
Declare that Value has the given Type. Succeeds if Value is bound to a value that's compatible with Type. Throws an informative exception if Value is bound to a value that's not compatible with Type. If Value is not bound, the type check is delayed until Value becomes ground.

When optimizations are enabled (current_prolog_flag(optimise, true)) a macro removes the entirely so that it always succeeds.

type_subtype(?Type, ?Subtype)[multifile]
Multifile predicate for declaring that a Type has a Subtype. It should only be necessary to add clauses to this predicate if has_subtype/2 has trouble deriving this information based on your definition of quickcheck:arbitrary/2.
has_subtype(+Type, +Subtype) is semidet
True if all values of Subtype are also values of Type. This can be used to determine whether arguments of one type can be passed to a predicate which demands arguments of another type.

This predicate performs probabilistic subtype detection by leveraging your definitions for error:has_type/2 and quickcheck:arbitrary/2. If this predicate is not detecting your types correctly, either improve your quickcheck:arbitrary/2 definition or add clauses to the multifile predicate type_subtype/2.

type_intersection(?Type, ?IntersectionType)[multifile]
Multifile predicate for declaring that Type has an IntersectionType. See type_subtype/2 for further details.
has_intersection(Type, IntersectionType) is semidet
True if some value of IntersectionType is also of Type. See has_subtype/2 for further details.
known_type(?Type:type) is semidet
True if Type is a type known to has_type/2. Iterates all known types on backtracking. Be aware that some types are polymorphic (like list(T)) so Type may be a non-ground term.

As a convenience, the type named type describes the set of all values for which known_type/1 is true.