summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra/Location.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/GF/Infra/Location.hs')
-rw-r--r--src/compiler/GF/Infra/Location.hs16
1 files changed, 11 insertions, 5 deletions
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)