In the Agda code base, show is (ab)used for pretty-printing things to display in error messages, debug messages, producing file names, etc.
However, the purpose of show is to print a Haskell representation, see also
http://hackage.haskell.org/package/pretty-show
Step 1: Replace uses of show in error messages, world communication etc. by uses of Agda.Utils.Pretty.prettyShow (and implement missing Pretty instances).
Step 2: Define a class and instances for debug printing and use it instead of show in debug print-outs. One could parametrize debug printing by a level of detail, see e.g.
http://hackage.haskell.org/package/prettyclass-1.0.0.0/docs/Text-PrettyPrint-HughesPJClass.html#t:PrettyLevel
Step 3: Derive or define Show instances for the datatypes of the Agda codebase.
Collections should be printed as Fully.Qualified.DataType.fromList ...
Original issue reported on code.google.com by [email protected] on 5 Oct 2014 at 12:48
I did step 1 for Abstract.Name.
pretty-show during debuggingThis is the transcript of a debugging session 2020-06-03 for #4709 carried out partially with @nad.
...and a toy run
cabal install pretty-show
ppsh --help
ppsh --html > foo.html
[Just 'a',Nothing]
^D
open foo.html
testcase.agda into agda root directory (cannot :cd in ghci).-Werr from Agda.cabalcabal v1-repl Agda
Wait a couple of minutes until all 371 modules are loaded.
We want to debug something in Agda.Syntax.Concrete.Operators starting line 624:
:m + Agda.Main
let main = runAgda []
:break Agda.Syntax.Concrete.Operators 624
:main testcase.agda
This stops at our breakpoint.
ppshNow let us inspect some values in scope, say p :: Pattern.
prettyShow p
print p
The latter produces a horrible blob, the Haskell representation of the pattern p. We can explore it using ppsh.
blob.hs. (Alternatively, we could paste it into stdin when running ppsh.)Range, ArgInfo and Fixity'. ppsh --html --hide=Range --hide=ArgInfo --hide=Fixity\' < blob.hs > blob.html
open blob.html
Here we can collapse and expand parts and thus explore the value interactively.
We can bring some functions into scope and evaluate.
:m + Agda.Syntax.Concrete.Operators
patternQNames p
We can step, e.g. staying inside the current module.
:stepmodule
Just a single :step is usually to fine-grained, e.g., getting us into the >>= function of the TCM monad.
Maybe the best way to step is to set the next breakpoint and then :continue.
* Remove `-Werr` from `Agda.cabal`
I wonder why GHCi complains when GHC doesn't.
* Remove `-Werr` from `Agda.cabal`I wonder why GHCi complains when GHC doesn't.
Today I loaded up and ran Agda in GHCi 8.10.2 without changing Agda.cabal. (Occasionally the program crashed due to a segmentation fault.) Sometimes when I changed a Haskell file reloading only took a few seconds.