cleanup compactify, improve
[clean-tests.git] / datatype / Printer.hs
index 1a7b1d1..f200b15 100644 (file)
@@ -25,7 +25,7 @@ localctx :: Ctx -> Printer a -> Printer a
 localctx ctx = local $ \r->r { context=ctx }
 
 iindent :: Printer a -> Printer a
-iindent p = local (\r->r { indent=indent r + 1 }) $ printIndent >> p
+iindent p = printIndent >> local (\r->r { indent=indent r + 1 }) p
 
 leftctx,rightctx,nonectx :: Int -> Ctx
 leftctx p = CtxInfix {assoc=CtxLeft, prio=p, branch=CtxNone}
@@ -69,6 +69,7 @@ needsParen (CtxInfix thisassoc thisprio _) (CtxInfix outerassoc outerprio outerb
     | otherwise = False
 needsParen _ CtxNullary = error "shouldn't occur"
 
+instance DSL Printer
 instance Expression Printer where
     lit = printLit . show
     (+.) = printBinOp (leftctx 6) "+"
@@ -155,7 +156,7 @@ printUnOp thisctx op l = paren' thisctx $
     >-> localctx (setBranch thisctx CtxRight) l
 
 printCons :: String -> Printer a -> Printer a
-printCons = printUnOp CtxNonfix-- . (++" ")
+printCons cons l = paren' CtxNonfix $ printLit cons >-> l
 
 printRec :: String -> Printer a -> Printer a
 printRec op l = printUnOp CtxNo op (accol l)-- (op++" ") (accol l)