mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-25 06:14:18 +00:00
Estimated hours taken: 60 Branches: main Allow users of the declarative debugger to revise answers that they have given previously. We do this by modifying the user interface to allow a default answer to be shown as part of the question; the default answer will always be some answer the user has given previously, which they can choose to either change or accept as is. Initially no questions will be candidates for revision, but if the user ever rejects a diagnosis, some or all of the questions leading directly to the bug in question will be asked again. Add an empty command to the user_command type, for when the user just presses return. If there is a default answer, the empty command is interpreted as that answer. If there is no default answer, the empty command is interpreted as the skip command, which allows the user to cycle through all the available questions by repeatedly pressing return. browser/declarative_debugger.m: Define the type decl_evidence which represents the evidence collected against a particular suspect. Pass the evidence to the oracle as required. Ensure the analyser is updated after the user rejects a diagnosis. browser/declarative_analyser.m: Collect the evidence against the prime suspect as the answers are processed, and include this evidence when the analyser response is a bug. Export the predicate revise_analysis/4 which updates the analyser state after the user has rejected a diagnosis. Pass the IO action map to prime_suspect_get_evidence so that edt_root_question can be called. browser/declarative_oracle.m: When the user rejects a bug, retract from the oracle's knowledge base any of the evidence which implicated that bug. Rather than throw this information away, we assert it in a secondary knowledge base which is consulted when we want to know if there should be a default answer provided to the user. Update the oracle_state to reflect the above change, and remove all the get_* and set_* predicates for the oracle state. That functionality is provided by labelled fields, so maintaining the get_* and set_* predicates is no longer worth the trouble. Add the predicate retract_oracle_kb/3 to remove information from a knowledge base. Use the correct (equivalence) type for exceptions. browser/declarative_user.m: Add the type user_question, which may be a plain decl_question or may be a decl_question with a default answer. Use this type in query_user* instead of decl_question. Write the command handling switch as a separate predicate. This makes it easier for one command to emulate others (e.g. the empty command). If the question has a default answer, print it as part of the prompt. Parse the empty command. doc/user_guide.texi: Update the documentation to reflect the changes. library/list.m: Add a cc_multi version of list__map. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/empty_command.exp: tests/debugger/declarative/empty_command.inp: tests/debugger/declarative/empty_command.m: tests/debugger/declarative/revise.exp: tests/debugger/declarative/revise.inp: tests/debugger/declarative/revise.m: tests/debugger/declarative/revise_2.exp: tests/debugger/declarative/revise_2.inp: tests/debugger/declarative/revise_2.m: Test cases for the new features.
22 lines
379 B
Mathematica
22 lines
379 B
Mathematica
:- module empty_command.
|
|
:- interface.
|
|
:- import_module io.
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
:- implementation.
|
|
|
|
main -->
|
|
{ p(53, P) },
|
|
io__write_int(P),
|
|
io__nl.
|
|
|
|
:- pred p(int::in, int::out) is det.
|
|
:- pred q(int::in, int::out) is det.
|
|
:- pred r(int::in, int::out) is det.
|
|
:- pred s(int::in, int::out) is det.
|
|
|
|
p --> q, r, s.
|
|
q --> [].
|
|
r --> [].
|
|
s --> [].
|
|
|