packages feed

s-cargot 0.1.5.0 → 0.1.6.0

raw patch · 4 files changed

+342/−96 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+v0.1.6.0+=======++Fixes:++* Some fixes to avoid trailing whitespace in pretty-printing.+  (Thank you, @kquick!)+ v0.1.5.0 ======= 
Data/SCargot/Print.hs view
@@ -35,7 +35,10 @@   -- | The 'Indent' type is used to determine how to indent subsequent---   s-expressions in a list, after printing the head of the list.+--   s-expressions in a list, after printing the head of the list.  This only+--   applies if the entire list cannot be printed within the allowable+--   'SExprPrinter.maxWidth'; a sub-maxWidth printing will not add newlines or+--   indentation. data Indent   = Swing -- ^ A 'Swing' indent will indent subsequent exprs some fixed           --   amount more than the current line.@@ -44,6 +47,9 @@           --   >   bar           --   >   baz           --   >   quux)+          --+          -- Any 'SExprPrinter.indentAmount' applies relative to the entry at the+          -- head of the list; in the above example, the indentAmount is 1.   | SwingAfter Int -- ^ A 'SwingAfter' @n@ indent will try to print the                    --   first @n@ expressions after the head on the same                    --   line as the head, and all after will be swung.@@ -52,9 +58,13 @@                    --   > (foo bar                    --   >   baz                    --   >   quux)-  | Align -- ^ An 'Align' indent will print the first expression after-          --   the head on the same line, and subsequent expressions will-          --   be aligned with that one.+                   --+                   -- The 'SExprPrinter.indentAmount' is handled in the same way+                   -- as for the 'Swing' setting.+  | Align -- ^ An 'Align' indent will print the first expression after the head+          -- on the same line, and subsequent expressions will be aligned with+          -- that one.  Note that this ignores any 'SExprPrinter.indentAmount'+          -- specified for the printer.           --           --   > (foo bar           --   >      baz@@ -75,28 +85,22 @@       -- ^ How to indent subsequent expressions, as determined by       --   the head of the list.   , indentAmount :: Int-      -- ^ How much to indent after a swung indentation.+      -- ^ How much to indent after a swung indentation, relative to the *head*+      -- element.   , maxWidth     :: Maybe Int-      -- ^ The maximum width (if any) If this is 'None' then the-      --   resulting s-expression might be printed on one line (if-      --   'indentPrint' is 'False') and might be pretty-printed in-      --   the most naive way possible (if 'indentPrint' is 'True').+      -- ^ The maximum width (if any) If this is 'None' then the resulting+      --   s-expression might be printed on one line (if+      --   'SExprPrinter.indentPrint' is 'False') and might be pretty-printed in+      --   the most naive way possible (if 'SExprPrinter.indentPrint' is 'True').   , indentPrint :: Bool-      -- ^ Whether to indent or not. This has been retrofitted onto+      -- ^ Whether to indent or not.   }   -- | A default 'SExprPrinter' struct that will always print a 'SExpr' --   as a single line. flatPrint :: (atom -> Text) -> SExprPrinter atom (SExpr atom)-flatPrint printer = SExprPrinter-  { atomPrinter  = printer-  , fromCarrier  = id-  , swingIndent  = const Swing-  , indentAmount = 2-  , maxWidth     = Nothing-  , indentPrint  = False-  }+flatPrint = (\p -> p { indentPrint = False}) . removeMaxWidth . basicPrint  -- | A default 'SExprPrinter' struct that will always swing subsequent --   expressions onto later lines if they're too long, indenting them@@ -118,14 +122,7 @@ -- but don't care about a "maximum" width, we can print more -- efficiently than in other situations. unconstrainedPrint :: (atom -> Text) -> SExprPrinter atom (SExpr atom)-unconstrainedPrint printer = SExprPrinter-  { atomPrinter  = printer-  , fromCarrier  = id-  , swingIndent  = const Swing-  , indentAmount = 2-  , maxWidth     = Nothing-  , indentPrint  = True-  }+unconstrainedPrint = removeMaxWidth . basicPrint  data Size = Size   { sizeSum :: !Int@@ -154,7 +151,7 @@  concatSize :: Size -> Size -> Size concatSize l r = Size-  { sizeSum = sizeSum l + 1 + sizeSum r+  { sizeSum = sizeSum l + 1 + sizeSum r  -- 1 for the ' ' between elements   , sizeMax = sizeMax l `max` sizeMax r   } @@ -172,7 +169,8 @@       IList sw sz hd rs Nothing     gather sw hd rs (SAtom a) sz =       IList sw (sz `concatSize` aSize) hd rs (Just aStr)-        where aSize = Size (T.length aStr) (T.length aStr)+        where aSize = Size aLen aLen+              aLen = T.length aStr + 2 -- 2 for the ". " between the pair               aStr = printAtom a     gather sw hd rs (SCons x xs) sz =       gather sw hd (rs Seq.|> x') xs (sz `concatSize` sizeOf x')@@ -235,7 +233,7 @@             in handleTail rest butLast      doIndent :: B.Builder -> B.Builder-    doIndent = doIndentOf (indentAmount spec)+    doIndent = doIndentOf (indentAmount spec + 1) -- 1 for '('      doIndentOf :: Int -> B.Builder -> B.Builder     doIndentOf n b = B.fromText (T.replicate n " ") <> b@@ -248,7 +246,9 @@     handleTail :: Maybe Text -> Seq.Seq B.Builder -> Seq.Seq B.Builder     handleTail Nothing = insertCloseParen     handleTail (Just t) =-      (Seq.|> (B.fromString " . " <> B.fromText t <> B.singleton ')'))+      let txtInd = B.fromText $ T.replicate (indentAmount spec) " "+          sep = B.fromString " . "+      in (Seq.|> (txtInd <> sep <> B.fromText t <> B.singleton ')'))      insertCloseParen :: Seq.Seq B.Builder -> Seq.Seq B.Builder     insertCloseParen s = case Seq.viewr s of@@ -355,7 +355,9 @@ -- Indents every line n spaces, and adds a newline to the beginning -- used in swung indents indentAllS :: Int -> Seq.Seq B.Builder -> B.Builder-indentAllS n = ("\n" <>) . joinLinesS . fmap (indent n)+indentAllS n s = if Seq.null s+                 then ""+                 else ("\n" <>) $ joinLinesS $ fmap (indent n) s  -- Indents every line but the first by some amount -- used in aligned indents@@ -399,28 +401,29 @@         -- the head is the pretty-printed head, with an ambient         -- indentation of +1 to account for the left paren         hd = pp (ind+1) h-        headWidth = sizeSum (sizeOf h)         indented =           case i of             SwingAfter n ->               let (l, ls) = Seq.splitAt n values-                  t  = unwordsS (fmap (pp (ind+1)) l)-                  ts = indentAllS (ind + indentAmount)-                       (fmap (pp (ind + indentAmount)) ls)-              in t <> ts+                  t  = unwordsS (fmap (pp (ind+1+1)) l) -- 1 for (, 1 for ' '+                  nextInd = ind + indentAmount + 1 -- 1 for (+                  ts = indentAllS nextInd (fmap (pp nextInd) ls)+              in B.singleton ' ' <> t <> ts             Swing ->-              indentAllS (ind + indentAmount)-                (fmap (pp (ind + indentAmount)) values)+              let nextInd = ind + indentAmount + 1 -- 1 for (+              in indentAllS nextInd (fmap (pp nextInd) values)             Align ->-              indentSubsequentS (ind + headWidth + 1)-                (fmap (pp (ind + headWidth + 1)) values)+              let headWidth = sizeSum (sizeOf h)+                  nextInd = ind + headWidth + 1 + 1 -- 1 for (, 1 for ' ' below+              in B.singleton ' ' <>+                 indentSubsequentS nextInd (fmap (pp nextInd) values)         body           -- if there's nothing here, then we don't have anything to           -- indent           | length values == 0 = mempty           -- if we can't fit the whole next s-expression on the same           -- line, then we use the indented form-          | sizeSum sz + ind > maxAmt = B.singleton ' ' <> indented+          | sizeSum sz + ind > maxAmt = indented           | otherwise =             -- otherwise we print the whole thing on one line!             B.singleton ' ' <> unwordsS (fmap (pp (ind + 1)) values)
s-cargot.cabal view
@@ -1,5 +1,5 @@ name:                s-cargot-version:             0.1.5.0+version:             0.1.6.0 synopsis:            A flexible, extensible s-expression library. homepage:            https://github.com/aisamanra/s-cargot description:         S-Cargot is a library for working with s-expressions in
test/SCargotPrintParse.hs view
@@ -24,96 +24,331 @@                                                 , "test/med2-sample.sexp"                                                 , "test/big-sample.sexp"                                                 ]-  counts <- runTestTT $ TestList+  counts <- runTestTT $ TestList $+            let+              -- l2p = list of 2 pairs+              l2p = (SCons+                      (SCons+                        (SAtom (AIdent "hi"))+                        (SAtom (AIdent "hallo")))+                      (SCons+                        (SAtom (AIdent "world"))+                        (SAtom (AIdent "welt"))))+              -- l3sp = list of 3 starting in a pair+              l3sp = (SCons+                       (SCons+                         (SAtom (AIdent "hi"))+                         (SAtom (AIdent "world")))+                       (SCons+                         (SAtom (AIdent "hallo"))+                         (SCons+                           (SAtom (AIdent "welt"))+                           SNil)))+              -- l3ep = list of 3 ending in a pair+              l3ep = (SCons+                       (SAtom (AIdent "hi"))+                       (SCons+                         (SAtom (AIdent "world"))+                         (SCons+                           (SAtom (AIdent "hallo"))+                           (SAtom (AIdent "welt")))))+              -- l3 = list of 3+              l3 = (SCons+                     (SAtom (AIdent "hi"))+                     (SCons+                       (SAtom (AIdent "world"))+                       (SCons+                         (SAtom (AIdent "hallo"))+                         SNil)))+              -- l5p = list of 5 pairs+              l5p = (SCons+                      (SCons+                        (SAtom (AIdent "hi"))+                        (SAtom (AIdent "world")))+                      (SCons+                        (SCons+                          (SAtom (AIdent "hallo"))+                          (SAtom (AIdent "welt")))+                        (SCons+                          (SCons+                            (SAtom (AIdent "bonjour"))+                            (SAtom (AIdent "monde")))+                          (SCons+                            (SCons+                              (SAtom (AIdent "hola"))+                              (SAtom (AIdent "mundo")))+                            (SCons+                              (SAtom (AIdent "ciao"))+                              (SAtom (AIdent "mundo")))))))+              -- l2 = list of 2+              l2 = (SCons+                     (SAtom (AIdent "hi"))+                     (SCons+                       (SAtom (AIdent "world"))+                       SNil))+              -- l1 = list of 1+              l1 = (SCons (SAtom (AIdent "hi")) SNil)+              pair = (SCons (SAtom (AIdent "hi")) (SAtom (AIdent "world")))+              -- linl = list within a list+              linl = (SCons+                         (SAtom (AIdent "hi"))+                         (SCons+                           (SCons+                            (SAtom (AIdent "world"))+                            (SCons+                              (SAtom (AIdent "and"))+                              (SCons+                                (SAtom (AIdent "people"))+                                SNil)))+                           (SCons+                            (SAtom (AIdent "hallo"))+                            (SCons+                             (SAtom (AIdent "welt"))+                             (SCons+                               (SAtom (AIdent "und"))+                               (SCons+                                 (SAtom (AIdent "leute"))+                                 SNil))))))+            in             [ TestLabel "basic checks" $ TestList               [ TestLabel "flat print" $ TestList                 [ TestLabel "flatprint SNil" $ "()" ~=? printSExpr SNil                 , TestLabel "flatprint SAtom" $ "hi" ~=? printSExpr (SAtom (AIdent "hi"))                 , TestLabel "flatprint pair" $ "(hi . world)" ~=?-                  printSExpr (SCons (SAtom (AIdent "hi")) (SAtom (AIdent "world")))+                  printSExpr pair                 , TestLabel "flatprint list of 1" $ "(hi)" ~=?-                  printSExpr (SCons (SAtom (AIdent "hi")) SNil)+                  printSExpr l1                 , TestLabel "flatprint list of 2" $ "(hi world)" ~=?-                  printSExpr (SCons (SAtom (AIdent "hi"))-                                    (SCons (SAtom (AIdent "world"))-                                           SNil))+                  printSExpr l2                 , TestLabel "flatprint list of 2 pairs" $ "((hi . hallo) world . welt)" ~=?-                  printSExpr (SCons (SCons (SAtom (AIdent "hi"))-                                           (SAtom (AIdent "hallo")))-                                    (SCons (SAtom (AIdent "world"))-                                           (SAtom (AIdent "welt"))))+                  printSExpr l2p+                , TestLabel "flatprint list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world) hallo welt)" ~=?+                  printSExpr l3sp                 , TestLabel "flatprint list of 3 ending in a pair" $ "(hi world hallo . welt)" ~=?-                  printSExpr (SCons (SAtom (AIdent "hi"))-                                    (SCons (SAtom (AIdent "world"))-                                           (SCons (SAtom (AIdent "hallo"))-                                                  (SAtom (AIdent "welt")))))+                  printSExpr l3ep                 , TestLabel "flatprint list of 3" $ "(hi world hallo)" ~=?-                  printSExpr (SCons (SAtom (AIdent "hi"))-                                    (SCons (SAtom (AIdent "world"))-                                           (SCons (SAtom (AIdent "hallo"))-                                                  SNil)))+                  printSExpr l3+                , TestLabel "flatprint pair of list of 4" $ "(hi (world and people) hallo welt und leute)" ~=?+                  printSExpr linl+                , TestLabel "flatprint list of 5 pairs" $+                  "((hi . world) (hallo . welt) (bonjour . monde) (hola . mundo) ciao . mundo)" ~=?+                  printSExpr l5p                 ] -              , TestLabel "pretty print" $+              , TestLabel "pretty print width 40" $                 let pprintIt = pprintSExpr 40 Swing in TestList                 [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil                 , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))                 , TestLabel "pretty print pair" $ "(hi . world)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi")) (SAtom (AIdent "world")))+                  pprintIt pair                 , TestLabel "pretty print list of 1" $ "(hi)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi")) SNil)+                  pprintIt l1                 , TestLabel "pretty print list of 2" $ "(hi world)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi"))-                                  (SCons (SAtom (AIdent "world"))-                                         SNil))+                  pprintIt l2                 , TestLabel "pretty print list of 2 pairs" $                   "((hi . hallo) world . welt)" ~=?-                  pprintIt (SCons (SCons (SAtom (AIdent "hi"))-                                         (SAtom (AIdent "hallo")))-                                  (SCons (SAtom (AIdent "world"))-                                         (SAtom (AIdent "welt"))))+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world) hallo welt)" ~=?+                  pprintIt l3sp                 , TestLabel "pretty print list of 3 ending in a pair" $                   "(hi world hallo . welt)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi"))-                                  (SCons (SAtom (AIdent "world"))-                                         (SCons (SAtom (AIdent "hallo"))-                                                (SAtom (AIdent "welt")))))+                  pprintIt l3ep                 , TestLabel "pretty print list of 3" $ "(hi world hallo)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi"))-                                  (SCons (SAtom (AIdent "world"))-                                         (SCons (SAtom (AIdent "hallo"))-                                                SNil)))+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $ "(hi\n  (world and people)\n  hallo\n  welt\n  und\n  leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world)\n  (hallo . welt)\n  (bonjour . monde)\n  (hola . mundo)\n  ciao . mundo)" ~=?+                  pprintIt l5p                 ] +              , TestLabel "pretty print width 10" $+                let pprintIt = pprintSExpr 10 Swing in TestList+                [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil+                , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))+                , TestLabel "pretty print pair" $ "(hi . world)" ~=?+                  pprintIt pair+                , TestLabel "pretty print list of 1" $ "(hi)" ~=?+                  pprintIt l1+                , TestLabel "pretty print list of 2" $ "(hi world)" ~=?+                  pprintIt l2+                , TestLabel "pretty print list of 2 pairs" $+                  "((hi . hallo)\n  world . welt)" ~=?+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world)\n  hallo\n  welt)" ~=?+                  pprintIt l3sp+                , TestLabel "pretty print list of 3 ending in a pair" $+                  "(hi\n  world\n  hallo . welt)" ~=?+                  pprintIt l3ep+                , TestLabel "pretty print list of 3" $ "(hi\n  world\n  hallo)" ~=?+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $ "(hi\n  (world\n    and\n    people)\n  hallo\n  welt\n  und\n  leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world)\n  (hallo . welt)\n  (bonjour . monde)\n  (hola . mundo)\n  ciao . mundo)" ~=?+                  pprintIt l5p+                ]++              , TestLabel "pretty print width 10 indent 5" $+                let pprintIt = encodeOne (setIndentStrategy (const Swing) $+                                          setIndentAmount 5 $+                                          setMaxWidth 10 $+                                          basicPrint printAtom)+                in TestList+                [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil+                , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))+                , TestLabel "pretty print pair" $ "(hi . world)" ~=?+                  pprintIt pair+                , TestLabel "pretty print list of 1" $ "(hi)" ~=?+                  pprintIt l1+                , TestLabel "pretty print list of 2" $ "(hi world)" ~=?+                  pprintIt l2+                , TestLabel "pretty print list of 2 pairs" $+                  "((hi . hallo)\n      world . welt)" ~=?+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world)\n      hallo\n      welt)" ~=?+                  pprintIt l3sp+                , TestLabel "pretty print list of 3 ending in a pair" $+                  "(hi\n      world\n      hallo . welt)" ~=?+                  pprintIt l3ep+                , TestLabel "pretty print list of 3" $+                  "(hi\n      world\n      hallo)" ~=?+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $ "(hi\n      (world\n            and\n            people)\n      hallo\n      welt\n      und\n      leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world)\n      (hallo . welt)\n      (bonjour . monde)\n      (hola . mundo)\n      ciao . mundo)" ~=?+                  pprintIt l5p+                ]++              , TestLabel "pretty print width 10 swing-after 3" $+                let pprintIt = pprintSExpr 10 (SwingAfter 3) in TestList+                [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil+                , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))+                , TestLabel "pretty print pair" $ "(hi . world)" ~=?+                  pprintIt pair+                , TestLabel "pretty print list of 1" $ "(hi)" ~=?+                  pprintIt l1+                , TestLabel "pretty print list of 2" $ "(hi world)" ~=?+                  pprintIt l2+                , TestLabel "pretty print list of 2 pairs" $+                  -- pairs are not split internally+                  "((hi . hallo) world . welt)" ~=?+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world) hallo welt)" ~=?+                  pprintIt l3sp+                , TestLabel "pretty print list of 3 ending in a pair" $+                  -- pairs are not split internally+                  "(hi world hallo . welt)" ~=?+                  pprintIt l3ep+                , TestLabel "pretty print list of 3" $ "(hi world hallo)" ~=?+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $+                  -- atom list pair\n ...+                  "(hi (world and people) hallo welt\n  und\n  leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world) (hallo . welt) (bonjour . monde) (hola . mundo)\n  ciao . mundo)" ~=?+                  pprintIt l5p+                ]++              , TestLabel "pretty print width 10 aligned" $+                let pprintIt = pprintSExpr 10 Align in TestList+                [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil+                , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))+                , TestLabel "pretty print pair" $ "(hi . world)" ~=?+                  pprintIt pair+                , TestLabel "pretty print list of 1" $ "(hi)" ~=?+                  pprintIt l1+                , TestLabel "pretty print list of 2" $ "(hi world)" ~=?+                  pprintIt l2+                , TestLabel "pretty print list of 2 pairs" $+                  "((hi . hallo) world . welt)" ~=?+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world) hallo\n              welt)" ~=?+                  pprintIt l3sp+                , TestLabel "pretty print list of 3 ending in a pair" $+                  "(hi world\n    hallo . welt)" ~=?+                  pprintIt l3ep+                , TestLabel "pretty print list of 3" $ "(hi world\n    hallo)" ~=?+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $+                  "(hi (world and\n           people)\n    hallo\n    welt\n    und\n    leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world) (hallo . welt)\n              (bonjour . monde)\n              (hola . mundo)\n              ciao . mundo)" ~=?+                  pprintIt l5p+                ]++              , TestLabel "pretty print width 400" $+                let pprintIt = pprintSExpr 400 Swing in TestList+                [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil+                , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))+                , TestLabel "pretty print pair" $ "(hi . world)" ~=?+                  pprintIt pair+                , TestLabel "pretty print list of 1" $ "(hi)" ~=?+                  pprintIt l1+                , TestLabel "pretty print list of 2" $ "(hi world)" ~=?+                  pprintIt l2+                , TestLabel "pretty print list of 2 pairs" $+                  -- No Swing if it fits on a line+                  "((hi . hallo) world . welt)" ~=?+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world) hallo welt)" ~=?+                  pprintIt l3sp+                , TestLabel "pretty print list of 3 ending in a pair" $+                  "(hi world hallo . welt)" ~=?+                  pprintIt l3ep+                , TestLabel "pretty print list of 3" $ "(hi world hallo)" ~=?+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $ "(hi (world and people) hallo welt und leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world) (hallo . welt) (bonjour . monde) (hola . mundo) ciao . mundo)" ~=?+                  pprintIt l5p+                ]+               , TestLabel "unconstrained print" $                 let pprintIt = ucPrintSExpr Swing in TestList                 [ TestLabel "pretty print SNil" $ "()" ~=? pprintIt SNil                 , TestLabel "pretty print SAtom" $ "hi" ~=? pprintIt (SAtom (AIdent "hi"))                 , TestLabel "pretty print pair" $ "(hi . world)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi")) (SAtom (AIdent "world")))+                  pprintIt pair                 , TestLabel "pretty print list of 1" $ "(hi)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi")) SNil)+                  pprintIt l1                 , TestLabel "pretty print list of 2" $ "(hi world)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi"))-                                  (SCons (SAtom (AIdent "world"))-                                         SNil))+                  pprintIt l2                 , TestLabel "pretty print list of 2 pairs" $-                  "((hi . hallo)\n world\n . welt)" ~=?-                  pprintIt (SCons (SCons (SAtom (AIdent "hi"))-                                         (SAtom (AIdent "hallo")))-                                  (SCons (SAtom (AIdent "world"))-                                         (SAtom (AIdent "welt"))))+                  "((hi . hallo)\n  world\n  . welt)" ~=?+                  pprintIt l2p+                , TestLabel "pretty print list of 3 starting in a pair" $+                  -- pairs count as a single element+                  "((hi . world)\n  hallo\n  welt)" ~=?+                  pprintIt l3sp                 , TestLabel "pretty print list of 3 ending in a pair" $                   "(hi world hallo . welt)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi"))-                                  (SCons (SAtom (AIdent "world"))-                                         (SCons (SAtom (AIdent "hallo"))-                                                (SAtom (AIdent "welt")))))+                  pprintIt l3ep                 , TestLabel "pretty print list of 3" $ "(hi world hallo)" ~=?-                  pprintIt (SCons (SAtom (AIdent "hi"))-                                  (SCons (SAtom (AIdent "world"))-                                         (SCons (SAtom (AIdent "hallo"))-                                                SNil)))+                  pprintIt l3+                , TestLabel "pretty print pair of list of 4" $ "(hi\n  (world and people)\n  hallo\n  welt\n  und\n  leute)" ~=?+                  pprintIt linl+                , TestLabel "pretty print list of 5 pairs" $+                  "((hi . world)\n  (hallo . welt)\n  (bonjour . monde)\n  (hola . mundo)\n  ciao\n  . mundo)" ~=?+                  pprintIt l5p                 ]                ]