Permalink
Browse files

Add pretty printer for stacks

  • Loading branch information...
1 parent d01d47a commit 7dc29f0217e4fdf9d7aaf561e939d2d9b44d9b4c @batterseapower committed Jul 9, 2010
Showing with 14 additions and 1 deletion.
  1. +7 −0 Evaluator/Syntax.hs
  2. +7 −1 Utilities.hs
View
@@ -20,3 +20,10 @@ data StackFrame = Apply (Out Var)
| PrimApply PrimOp [In TaggedValue] [In TaggedTerm]
| Update (Out Var)
deriving (Show)
+
+instance Pretty StackFrame where
+ pPrintPrec level prec kf = case kf of
+ Apply x' -> pPrintPrecApp level prec (text "[_]") x'
+ Scrutinise in_alts -> pPrintPrecCase level prec (text "[_]") (renameIn renameTaggedAlts prettyIdSupply in_alts)
+ PrimApply pop in_vs in_es -> pPrintPrecPrimOp level prec pop (map SomePretty in_vs ++ map SomePretty in_es)
+ Update x' -> pPrintPrecApp level prec (text "update") x'
View
@@ -1,4 +1,4 @@
-{-# LANGUAGE TupleSections, PatternGuards #-}
+{-# LANGUAGE TupleSections, PatternGuards, ExistentialQuantification #-}
module Utilities (
module IdSupply,
module Utilities,
@@ -205,6 +205,12 @@ pPrintTuple :: [Doc] -> Doc
pPrintTuple ds = parens $ fsep $ punctuate comma ds
+data SomePretty = forall a. Pretty a => SomePretty a
+
+instance Pretty SomePretty where
+ pPrintPrec level prec (SomePretty x) = pPrintPrec level prec x
+
+
newtype PrettyFunction = PrettyFunction (PrettyLevel -> Rational -> Doc)
instance Pretty PrettyFunction where

0 comments on commit 7dc29f0

Please sign in to comment.