1
0
forked from GitHub/gf-core

Preliminary new shell feature: cc -trace.

You can now do things like 

	cc -trace mkV "debug"

to see a trace of all opers with their arguments and results during the
computation of mkV "debug".
This commit is contained in:
hallgren
2015-09-28 22:23:56 +00:00
parent 82f238fe2b
commit 35be182824
8 changed files with 89 additions and 40 deletions

View File

@@ -25,10 +25,16 @@ noLoc = L NoLoc
ppLocation :: FilePath -> Location -> Doc
ppLocation fpath NoLoc = pp fpath
ppLocation fpath (External p l) = ppLocation p l
ppLocation fpath (Local b e)
| b == e = fpath <> ":" <> b
| otherwise = fpath <> ":" <> b <> "-" <> e
ppLocation fpath (Local b e) =
opt (fpath/="") (fpath <> ":") <> b <> opt (b/=e) ("-" <> e)
where
opt False x = empty
opt True x = x
ppL (L loc x) msg = hang (loc<>":") 4 ("In"<+>x<>":"<+>msg)
ppL (L loc x) msg = hang (ppLocation "" loc<>":") 4
("In"<+>x<>":"<+>msg)
instance Pretty Location where pp = ppLocation ""
instance Pretty a => Pretty (L a) where pp (L loc x) = loc<>":"<>x