summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra/CheckM.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2014-07-27 22:06:23 +0000
committerhallgren <hallgren@chalmers.se>2014-07-27 22:06:23 +0000
commit30cda5151651e712803527b6ab4e5abc07536f2c (patch)
tree3c111f33a80fe5e1ea3e1cb40a968289a8b11425 /src/compiler/GF/Infra/CheckM.hs
parent7eaea44386acb6b5f71806e649850629470441f8 (diff)
Introducing GF.Text.Pretty for more concise pretty printers and GF.Infra.Location for modularity
GF.Text.Pretty provides the class Pretty and overloaded versions of the pretty printing combinators in Text.PrettyPrint, allowing pretty printable values to be used directly instead of first having to convert them to Doc with functions like text, int, char and ppIdent. Some modules have been converted to use GF.Text.Pretty, but not all. Precedences could be added to simplify the pretty printers for terms and patterns. GF.Infra.Location contains the types Location and L, factored out from GF.Grammar.Grammar, and the class HasSourcePath. This allowed the import of GF.Grammar.Grammar to be removed from GF.Infra.CheckM, making it more like a pure library module.
Diffstat (limited to 'src/compiler/GF/Infra/CheckM.hs')
-rw-r--r--src/compiler/GF/Infra/CheckM.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/compiler/GF/Infra/CheckM.hs b/src/compiler/GF/Infra/CheckM.hs
index 045ba4852..24fbc3644 100644
--- a/src/compiler/GF/Infra/CheckM.hs
+++ b/src/compiler/GF/Infra/CheckM.hs
@@ -21,11 +21,11 @@ module GF.Infra.CheckM
import GF.Data.Operations
--import GF.Infra.Ident
-import GF.Grammar.Grammar(msrc) -- ,Context
-import GF.Grammar.Printer(ppLocation)
+--import GF.Grammar.Grammar(msrc) -- ,Context
+import GF.Infra.Location(ppLocation,sourcePath)
import qualified Data.Map as Map
-import Text.PrettyPrint
+import GF.Text.Pretty
import System.FilePath(makeRelative)
import Control.Parallel.Strategies(parList,rseq,using)
import Control.Monad(liftM)
@@ -51,7 +51,7 @@ instance Monad Check where
(ws,Fail msg) -> (ws,Fail msg)
instance ErrorMonad Check where
- raise s = checkError (text s)
+ raise s = checkError (pp s)
handle f h = handle' f (h . render)
handle' f h = Check (\{-ctxt-} msgs -> case unCheck f {-ctxt-} msgs of
@@ -67,7 +67,7 @@ checkCond s b = if b then return () else checkError s
-- | warnings should be reversed in the end
checkWarn :: Message -> Check ()
-checkWarn msg = Check $ \{-ctxt-} (es,ws) -> ((es,(text "Warning:" <+> msg) : ws),Success ())
+checkWarn msg = Check $ \{-ctxt-} (es,ws) -> ((es,("Warning:" <+> msg) : ws),Success ())
checkWarnings = mapM_ checkWarn
@@ -151,6 +151,6 @@ checkIn msg c = Check $ \{-ctxt-} msgs0 ->
-- | Augment error messages with a relative path to the source module and
-- an contextual hint (which can be left 'empty')
checkInModule cwd mi loc context =
- checkIn (ppLocation relpath loc <> colon $$ nest 2 context)
+ checkIn (ppLocation relpath loc <> ':' $$ nest 2 context)
where
- relpath = makeRelative cwd (msrc mi)
+ relpath = makeRelative cwd (sourcePath mi)