Declarative debugging of lazy FP
Declarative debugging of lazy functional programs
Lee Naish
We show how declarative (or algorithmic) debugging can be applied
to lazy functional programming and describe a prototype
implementation. We first present a declarative debugger for
logic programs which relies on three primitives that determine if
an atom is valid in the intended interpretation, return the
successful clause instance used by a call and return single atoms
from a conjunction of atoms. By simply using different
interpretations and versions of these three primitives the
debugger can be used to locate errors in strict and non-strict
functional programs. Debugging strict code is essentially the
same as debugging Horn clause programs. Debugging non-strict
code can result in questions containing unevaluated expressions.
These questions can be simplified by using quantified variables.
The prototype system is based on
NUE-Prolog
,
which supports a
functional language on top of NU-Prolog and is implemented using
the flattening transformation. The implementation has been
modified so functional code returns a representation of the
computation which is then passed to the debugger. The basic
algorithm is applicable to other functional programming languages
also.
Keywords: functional programming, lazy evaluation, declarative
debugging, logic programming.
Lee