From 94eddd3b425fe944bb1e2bc228e903cc3d4b6253 Mon Sep 17 00:00:00 2001 From: notoria Date: Fri, 19 Jun 2020 17:18:59 +0200 Subject: [PATCH 1/2] Added library(debug) --- src/lib/debug.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/lib/debug.pl diff --git a/src/lib/debug.pl b/src/lib/debug.pl new file mode 100644 index 00000000..bc9f9df8 --- /dev/null +++ b/src/lib/debug.pl @@ -0,0 +1,22 @@ +% Source: https://stackoverflow.com/a/30791637 + +:- module(debug, [ + op(900, fx, $), + op(900, fx, $-), + op(950, fy, *), + (*)/1, + ($)/1, + ($-)/1 +]). + +:- use_module(library(format), [portray_clause/1]). + +$-(G_0) :- + catch(G_0, Ex, ( portray_clause(exception:Ex:G_0), throw(Ex) ) ). + +$(G_0) :- + portray_clause(call:G_0), + $-G_0, + portray_clause(exit:G_0). + +*(_). From 1799c1993346330eaa5747900ab8bf76df8efd5f Mon Sep 17 00:00:00 2001 From: notoria Date: Fri, 19 Jun 2020 17:48:55 +0200 Subject: [PATCH 2/2] Added an entry in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c7e6281f..1e7e3a6c 100644 --- a/README.md +++ b/README.md @@ -378,6 +378,8 @@ The modules that ship with Scryer Prolog are also called write `integer_si(X)` to ensure soundness of your programs. "si" stands for *sufficiently instantiated*, and also for *sound inference*. +* [`debug`](src/lib/debug.pl) + Various predicates that allow for declarative debugging. * [`pio`](src/lib/pio.pl) `phrase_from_file/2` applies a DCG nonterminal to the contents of a file, reading lazily only as much as is needed. Due to the compact