Browse Source

Fix indentation in basicPrint algorithm

Getty Ritter 5 years ago
parent
commit
71d2ec896f
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Data/SCargot/Print.hs

+ 3 - 3
Data/SCargot/Print.hs

@@ -145,11 +145,12 @@ data Intermediate
   -- final improper element (if it exists)
   | IEmpty
   -- ^ An empty list
+    deriving Show
 
 sizeOf :: Intermediate -> Size
 sizeOf IEmpty = Size 2 2
 sizeOf (IAtom t) = Size len len where len = T.length t
-sizeOf (IList _ s _ _ _) = s
+sizeOf (IList _ (Size n m) _ _ _) = Size (n + 2) (m + 2)
 
 concatSize :: Size -> Size -> Size
 concatSize l r = Size
@@ -348,7 +349,7 @@ unwordsS s = case Seq.viewl s of
   Seq.EmptyL -> ""
   t Seq.:< ts
     | F.null ts -> t
-    | otherwise -> t <> " " <> joinLinesS ts
+    | otherwise -> t <> " " <> unwordsS ts
 
 
 -- Indents every line n spaces, and adds a newline to the beginning
@@ -356,7 +357,6 @@ unwordsS s = case Seq.viewl s of
 indentAllS :: Int -> Seq.Seq B.Builder -> B.Builder
 indentAllS n = ("\n" <>) . joinLinesS . fmap (indent n)
 
-
 -- Indents every line but the first by some amount
 -- used in aligned indents
 indentSubsequentS :: Int -> Seq.Seq B.Builder -> B.Builder