1:- module(insist, [insist/1,insist/2, insist/3]).

Tools for enforcing conditions

This module provides what are usually called assertions in other languages, but of course the word 'assert' is already taken in Prolog. insist/1 and insist/2 can be used to wrap any goal that is not allowed to fail. /

   10:- meta_predicate insist(0,:), insist(0), insist(+,0,:).   11
   12insist(G) :- insist(G,failed(G)).
   13insist(G,Ex) :- call(G) -> true; throw(Ex).
   14insist(det,G,Ex) :- insist(G,Ex).
   15insist(multi,G,Ex) :- call(G) *-> true; throw(Ex).
   16
   17user:goal_expansion(insist(G),X) :- user:goal_expansion(insist(G,failed(G)),X).
   18user:goal_expansion(insist(G,Ex),(G->true;throw(Ex))).
   19user:goal_expansion(insist(det,G,Ex),X) :- user:goal_expansion(insist(G,Ex),X).
   20user:goal_expansion(insist(multi,G,Ex),(G*->true;throw(Ex)))