[Update Hat webpage. malcolm**20020315123331] { hunk ./docs/index.html 13 +
+$ hat-observe Example + + hat-observe 1.12 (:h for help, :q to quit) + +hat-observe> main +1 main = IO (print (8,_|_)) +hat-observe> print +1 print (8,_|_) = IO (print (8,_|_)) +hat-observe> last' +1 last' [8,_,_] = _|_ +2 last' [_,_] = _|_ +3 last' [_] = _|_ +4 last' [] = _|_ +hat-observe> :quit +$ +hunk ./docs/index.html 114 -
-hat-observe "last'" Example --shows +Every reduction replaces an instance of the left-hand side of a program +equation by an instance of its right-hand side. The instance of the +left-hand side ``creates'' the instance of the right-hand side and is +therefore called its parent. With hat-trail you can obtain +the parent of any expression. + +
+(Note: if you cannot see any highlighting in the following diagram, +try changing the fixed-width font in your browser to something like +Courier text.) Each line of the trail is the parent of the highlighted +subexpression directly above it. + hunk ./docs/index.html 137 -last' (8:_:_:[]) = _|_ -last' (_:_:[]) = _|_ -last' (_:[]) = _|_ -last' [] = _|_ +Error: ------------------------------------------------------- +No match in pattern. +Output: ------------------------------------------------------ +(8, +Trail: ---------------------- Example.hs line: 2 col: 12 ----- +<- last' [] +<- last' [_] +<- last' [_,_] +<- last' [8,_,_] +<- 4 * 2 +<- xs hunk ./docs/index.html 151 +Here, the error message is chosen as the starting point, rather +than any of the output. The first trail is therefore +last' [], because its evaluation caused the error message. +The parent of last' [] is +last' [_]. The parent of last' [_] +is last' [_,_]), etc. The parent of the +subexpression 8 is 4*2 whose parent is +xs. +
+ hunk ./docs/index.html 162 -Hat-detect is an interactive tool that enables locating -semi-automatically an error in a program by answering a sequence -of yes/no questions. Each question asked by hat-detect concerns -the reduction of a redex - that is, a function application - to a -value. You have to answer yes, if the reduction is correct -with respect to your intentions, and no otherwise. After a -number of questions hat-detect states which reduction is the cause -of the observed faulty behaviour - that is, which function definition -is incorrect. +Hat-detect is an interactive tool that enables the semi-automatic +location of an error in a program by answering a sequence of yes/no +questions. Each question asked by hat-detect concerns the reduction +of a redex - that is, a function application - to a value. You have to +answer yes, if the reduction is correct with respect to your +intentions, and no otherwise. After a number of questions +hat-detect states which reduction is the cause of the observed faulty +behaviour - that is, which function definition is incorrect. hunk ./docs/index.html 174 -1> main = IO (print (3:3:3:[])) (Y/?/N): n - -2> sort (3:2:1:[]) = 3:3:3:[] (Y/?/N): n +$ hat-detect Example hunk ./docs/index.html 176 -3> insert 1 [] = 1:[] (Y/?/N): y + hat-detect 1.12 (:h for help, :q to quit) hunk ./docs/index.html 178 -4> insert 2 (1:[]) = 2:2:[] (Y/?/N): n - -5> insert 2 [] = 2:[] (Y/?/N): y +1 main = IO (print [3,3,3]) ? n +2 sort [3,2,1] = [3,3,3] ? n +3 insert 1 [] = [1] ? y +4 insert 2 [1] = [2,2] ? n +5 insert 2 [] = [2] ? y hunk ./docs/index.html 185 -Bug found: "insert 2 (1:[]) = 2:2:[]" +Bug found in reduction: insert 2 [1] = [2,2] hunk ./docs/index.html 188 -
-Every reduction replaces an instance of the left-hand side of a program -equation by an instance of its right-hand side. The instance of the -left-hand side ``creates'' the instance of the right-hand side and is -therefore called its parent. With hat-trail you can obtain -the parent of an expression. +For aborted computations, that is computations that terminated +with an error message or were interrupted, hat-stack shows in which +function call the computation was aborted. It does so by showing a +virtual stack of function calls (redexes). Thus, every function +call shown on the stack caused the function call above it. The evaluation +of the top stack element caused the error (or during its evaluation +the computation was interrupted). The stack shown is virtual, +because it does not correspond to the actual runtime stack. The actual +runtime stack enables lazy evaluation whereas the virtual +stack corresponds to a stack that would be used for eager (strict) +evaluation. hunk ./docs/index.html 204 -
+$ hat-stack Example +Program terminated with error: + "No match in pattern." +Virtual stack trace: source file/line/col + (last' []) Example.hs 6 16 + (last' (5+6:[])) Example.hs 6 16 + (last' ((div 5 0):5+6:[])) Example.hs 6 16 + (last' (8:(div 5 0):5+6:[])) Example.hs 4 27 + main Example.hs 2 1 +$ +hunk ./docs/index.html 218 -last' [] is the starting point, because its evaluation -caused an error message. The parent of last' [] is -last' (5+6:[]). The parent of last' (5+6:[]) -is last' (5 `div` 0:5+6:[]), etc. The parent of the -subexpression 8 is 4*2 whose parent is -xs. hunk ./docs/index.html 221 -