From 35be1828241bb8dacdf326810af388b7b349e591 Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 28 Sep 2015 22:23:56 +0000 Subject: 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". --- src/compiler/GF/Infra/Location.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/compiler/GF/Infra/Location.hs') diff --git a/src/compiler/GF/Infra/Location.hs b/src/compiler/GF/Infra/Location.hs index 36bfab044..0bf85b37f 100644 --- a/src/compiler/GF/Infra/Location.hs +++ b/src/compiler/GF/Infra/Location.hs @@ -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) + + +instance Pretty Location where pp = ppLocation "" + +instance Pretty a => Pretty (L a) where pp (L loc x) = loc<>":"<>x -ppL (L loc x) msg = hang (ppLocation "" loc<>":") 4 - ("In"<+>x<>":"<+>msg) -- cgit v1.2.3