Reputation: 797
I'm studying how dependent pattern matching works in agda. If I can see elaborated core terms(https://github.com/agda/agda/blob/master/src/full/Agda/Syntax/Internal.hs#L202) of arbitrary source code of .agda file, it will be really helpful for me.
However, agda cli seems not to offer any options for this usage. Is there any?
Upvotes: 2
Views: 143
Reputation: 2955
There's three options you could try depending on how much detail you want, though none of them are perfect:
If all you want is to see what implicit arguments Agda has inserted, you can enable the flags --show-implicit
and --show-irrelevant
, create a new hole with the term you want to inspect by adding _ = {! yourTerm !}
at the bottom of the file, reload the file with C-c C-l
, and then press C-u C-c C-m
with the cursor inside the hole. [Writing this out made me realize there ought to be a simpler way to do this.]
If you want to inspect and possibly manipulate the full AST of an Agda term, you can do so using the reflection API (https://agda.readthedocs.io/en/v2.6.2.1/language/reflection.html). In particular, you can get the reflected syntax of an arbitrary Agda term by using the quoteTerm
primitive.
Finally, if you need more information you can look in the source code of Agda itself and enable the debug flags for printing the information you want. Note that there is no guarantee that this debug information will be useful or even readable, as it is intended for use by the developers. With that being said, you could for example print the case tree generated from a definition by pattern matching by adding {-# OPTIONS -v tc.cc:12 #-}
at the top of your file. In Emacs, this debug information will end up in a separate buffer titled *Agda debug*
(which you'll have to open manually after loading the .agda file).
Upvotes: 2