Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Debugging and Testing Hets
Debugging and testing Hets
If Hets does not compile: try
Important: Hets is quite a large system. It is useful to first understand the central data structures of Hets by following the sample ghci session below.
Hets may be tested and debugged
- in a top-down manner, by calling hets on some libraries and inserting some trace output, or by simulating the hets command line with ghci, see below,
- or in a bottom-up manner, by testing and debugging individual modules.
Which way is better depends on the nature of your specific task, and on your personal preferences. Generally, bottom up should be prefered if this is possible, because this reduces complexity.
There are several tools for debugging and testing Hets:
- Interactive evaluation with ghci
- Regression tests
- Standalone versions of Hets
- Quick Check
- Interactive Tests
Interactive evaluation with ghci
make ghci, you can call the interactive Haskell interpreter ghci. Use
:l filename.hs to load your specific module (use
:r to reload the module if you have changed the sources). Then you can interactively test individual functions of your module.
You also can simulate the hets command line. Type in:
:l Scratch.hs Just (ln,libenv) <- process "test/Sorting1.casl"
and your file gets analysed and you can inspect the resulting data structures. Therefore, you probably need to load modules like Common/Id.hs as well:
A sample session is stored in the file sample-ghci-script that can be pointed to by a
.ghci file. Look into Static/DevGraph.hs (and also into Logic/Grothendieck.hs and CASL/Sign.hs) to understand the data structures involved.
It is advisable not to look into the (rather large) data structures directly, but instead inspect their types by:
:browse Main :browse Common.Id :t showId
and then further decompose them, as shown in the sample file.
If you have written a parser, you can test it by adding two lines to your source file:
import Common.AnnoState parse p inp = runParser p (emptyAnnos ()) "" inp
Then call at the ghci command prompt:
parse myParser myInputString
Debug.Trace.trace function, you can output trace information. Use
Common.DocUtils.showDoc for converting a value to a string. For example:
import Debug.Trace import Common.DocUtils f :: Show a => [a] -> [a] f x = trace ("x=" ++ show x) $ reverse x g :: Pretty a => [a] -> [a] g x = trace ("x=" ++ showDoc x "") $ reverse x
make check runs various regression tests partly using the following standalone programs.
Standalone versions of Hets
There are various standalone versions covering specific aspects of Hets:
- CASL parser:
- HasCASL parser:
- Haskell analysis:
- HasCASL to Haskell translation:
- HetCASL parser:
- HetCASL analysis:
- ATC test system:
- ATerm.Lib test system:
In order to translate hets with profiling, move away the uni and programatica directories. In the
HC_PROFILE and translate all packages with profiling by adding
configure of cabal's
Setup. Unregister the packages manually or
make package_clean before
make. (When switching off profiling later on, the packages don't need to be recompiled again.)
Also comment out
-DCASLEXTENSIONS if it's not needed. (Translated uni with profiling has not been tested yet.) The resulting hets binary now creates a file
hets.prof for inspection if executed with additional final arguments
hets -v2 -o prf Basic/Numbers.casl +RTS -p