Merge pull request #2847 from triska/call_with_error_context

ADDED: type pair
This commit is contained in:
Mark Thom
2025-03-09 13:21:25 -07:00
committed by GitHub

View File

@@ -37,6 +37,7 @@
% - list % - list
% - octet_character % - octet_character
% - octet_chars % - octet_chars
% - pair
% - term % - term
must_be(Type, Term) :- must_be(Type, Term) :-
@@ -83,6 +84,7 @@ must_be_(octet_chars, Cs) :-
must_be_(list, Term) :- check_(error:ilist, list, Term). must_be_(list, Term) :- check_(error:ilist, list, Term).
must_be_(type, Term) :- check_(error:type, type, Term). must_be_(type, Term) :- check_(error:type, type, Term).
must_be_(boolean, Term) :- check_(error:boolean, boolean, Term). must_be_(boolean, Term) :- check_(error:boolean, boolean, Term).
must_be_(pair, Term) :- check_(error:pair, pair, Term).
must_be_(term, Term) :- must_be_(term, Term) :-
( acyclic_term(Term) -> ( acyclic_term(Term) ->
( ground(Term) -> true ( ground(Term) -> true
@@ -105,6 +107,9 @@ check_(Pred, Type, Term) :-
; type_error(Type, Term, must_be/2) ; type_error(Type, Term, must_be/2)
). ).
pair(_-_).
boolean(B) :- ( B == true ; B == false ). boolean(B) :- ( B == true ; B == false ).
character(C) :- character(C) :-
@@ -140,6 +145,7 @@ type(var).
type(boolean). type(boolean).
type(term). type(term).
type(not_less_than_zero). type(not_less_than_zero).
type(pair).
%% can_be(Type, Term) %% can_be(Type, Term)
% %
@@ -188,6 +194,7 @@ can_(octet_chars, Cs) :-
). ).
can_(list, Term) :- list_or_partial_list(Term). can_(list, Term) :- list_or_partial_list(Term).
can_(boolean, Term) :- boolean(Term). can_(boolean, Term) :- boolean(Term).
can_(pair, Term) :- pair(Term).
can_(term, Term) :- can_(term, Term) :-
( acyclic_term(Term) -> ( acyclic_term(Term) ->
true true