diff --git a/CompState.hs b/CompState.hs index 02fcac9..1dd6ec8 100644 --- a/CompState.hs +++ b/CompState.hs @@ -44,6 +44,11 @@ data CompFrontend = FrontendOccam | FrontendRain -- | State necessary for compilation. data CompState = CompState { + -- This structure needs to be printable with pshow. + -- There are explicit rules for the Maps and Sets used here + -- in PrettyShow.hs; if you add any new ones here then remember + -- to add matching rules there. + -- Set by Main (from command-line options) csMode :: CompMode, csBackend :: CompBackend, diff --git a/Pass.hs b/Pass.hs index c35079d..64aa5f2 100644 --- a/Pass.hs +++ b/Pass.hs @@ -89,7 +89,7 @@ debugAST p veryDebug $ "}}}" veryDebug $ "{{{ State" ps <- get - veryDebug $ show ps + veryDebug $ pshow ps veryDebug $ "}}}" -- | Number lines in a piece of text. diff --git a/PrettyShow.hs b/PrettyShow.hs index e8abfc2..87697c1 100644 --- a/PrettyShow.hs +++ b/PrettyShow.hs @@ -24,6 +24,7 @@ module PrettyShow (pshow) where import Data.Generics import qualified Data.Map as Map +import qualified Data.Set as Set import Text.PrettyPrint.HughesPJ import qualified AST as A @@ -66,6 +67,9 @@ doMap :: (Data a, Data b) => Map.Map a b -> Doc doMap map = braces $ sep $ punctuate (text ",") [doAny k <+> text ":" <+> doAny v | (k, v) <- Map.toAscList map] +doSet :: Data a => Set.Set a -> Doc +doSet set = brackets $ sep $ punctuate (text ",") (map doAny $ Set.toList set) + foldPatternList :: Pattern -> [Pattern] foldPatternList (Match con patList) = if (showConstr con == "(:)") @@ -123,6 +127,8 @@ doAny = doGeneral `ext1Q` doList `extQ` doString `extQ` doMeta `extQ` doPattern `extQ` (doMap :: Map.Map String A.NameDef -> Doc) `extQ` (doMap :: Map.Map String [A.Type] -> Doc) `extQ` (doMap :: Map.Map String [A.Actual] -> Doc) + `extQ` (doSet :: Set.Set String -> Doc) + `extQ` (doSet :: Set.Set A.Name -> Doc) -- | Convert an arbitrary data structure to a string in a reasonably pretty way. -- This is currently rather slow.