| Did you know ... | Search Documentation: |
| Packs (add-ons) for SWI-Prolog |
| Title: | Runtime determinacy checker |
|---|---|
| Rating: | Not rated. Create the first rating! |
| Latest version: | 1.0.2 |
| SHA1 sum: | 8caf683808880c34cb3cf29f3bb0a956789557db |
| Author: | Raivo Laanemets http://rlaanemets.com/ |
| Home page: | https://github.com/rla/rdet |
No reviews. Create the first review!.
| Version | SHA1 | #Downloads | URL |
|---|---|---|---|
| 1.0.2 | 8caf683808880c34cb3cf29f3bb0a956789557db | 30 | https://github.com/rla/rdet.git |
| 1.0.1 | 67d43ab75ce1c1d4f61b7c3368fb3e741aa3901c | 1 | https://github.com/rla/rdet.git |
| afee76546bc60aadad03a386f5698943f61abeac | 1 | https://github.com/rla/rdet.git | |
| cbe6401d610c6710288cfdaed39ff85e6f8745ca | 27 | https://github.com/rla/rdet.git | |
| 1.0.0 | 2adddfdbcab4ad3d0970f2b4790b75b0ea2d22a5 | 6 | http://packs.rlaanemets.com/rdet/rdet-1.0.0.tgz |
| b2f02c0802e6db9af27a317c84f309d855e78029 | 5 | https://github.com/rla/rdet.git | |
| 0.0.2 | 3f3a15b6cbdb1e0064e2002f07dbfe5979eb6f74 | 20 | https://github.com/rla/rdet.git |
| 0.0.1 | c7cfc59602962142784d9ece67b576446aab7619 | 89 | http://packs.rlaanemets.com/rdet/rdet-0.0.1.tgz |
Many predicates dealing with databases and external systems are non-failure. These predicates have the following properties:
This library attempts to provide runtime check for these conditions.

Use directive rdet/1 to annotate predicates that are supposed to be deterministic:
:- rdet(somepred/arity).
When annotated predicate call fails, an error is thrown:
error(goal_failed(PredicateIndicator), _)
:- use_module(library(rdet)).
:- rdet(insert_sort/2).
:- rdet(i_sort/3).
:- rdet(insert/3).
insert_sort(List, Sorted):-
i_sort(List, [], Sorted).
i_sort([], Acc, Acc).
i_sort([H|T], Acc, Sorted):-
insert(H,Acc,NAcc),
i_sort(T,NAcc,Sorted).
insert(X,[Y|T],[Y|NT]):-
X>Y,
insert(X,T,NT).
insert(X,[Y|T],[X,Y|T]):-
X=<Y.
insert(X,[a],[X]).
Running the sorting procedure will throw an error (the last clause of insert/3 is intentionally made to fail with numbers):
?- insert_sort([2,4,1,3], Sorted). ERROR: Unhandled exception: Goal insert/3 failed.
The library uses SWI-Prolog built-in predicate wrap_predicate to insert
necessary checks.
Previous version of this library was using goal expansion.
Enable rdet debug statements (before loading code to be enhanced):
?- debug(rdet). Warning: rdet: no matching debug topic (yet) true. ?- [insert]. % rdet: adding goal: user:insert_sort/2 % rdet: adding goal: user:i_sort/3 % rdet: adding goal: user:insert/3 true.
Module named user usually contains the code that is not explicitly
put into a module.
Good luck building a static analysis system that includes the following:
And has all of this optional: you can combine your code easily with 3rd party untyped/unmoded libraries.
To install as a package:
pack_install(rdet).
It requires a recent SWI-Prolog version 8.x or newer.
In the package root, insert into swipl:
[tests/tests]. run_tests.
Or if you cloned the repo:
make test
Please send bug reports/feature request through the GitHub project page.
The MIT license. See the LICENSE file.
Pack contains 17 files holding a total of 9.9K bytes.