Open mndrix opened 11 years ago
This one is derived from the delta type in my tiny patches project. It's similar to algebraic data types in other languages.
:- type delta ---> +(atom, positive_integer)
; <(positive_integer, oneof([space,tab]), positive_integer)
.
which should expand into
:- multifile error:has_type/2.
error:has_type(delta, +(A,B)) :-
error:has_type(A, atom),
error:has_type(B, positive_integer).
error:has_type(delta, <(A,B,C)) :-
error:has_type(positive_integer, A),
error:has_type(oneof([space,tab]), B),
error:has_type(positive_integer, C).
Make sure that our type syntax is very close to (if not identical with) the syntax used by Mercury and SWI-Prolog's CHR system.
This sugary syntax should automatically generate clauses for quickcheck:arbitrary/2
, if possible. In most circumstances it will be trivial to do so. We certainly don't want to maintain those definitions by hand if we can avoid it.
Imagine the following two type definitions in mavis:
That's more verbose (and error prone) than I'd like. I'd prefer to write:
The basic notation is similar to Mercury while allowing arbitrary type checks (such as
even_integer
). This can be implemented with a relatively easyterm_expansion/2
macro.