Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 610acb7

Browse files
committed
Indent/newline.
1 parent 1a1bfc3 commit 610acb7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Serializing/SExpression/Precise.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ serializeSExpression :: ToSExpression t => t -> Builder
1313
serializeSExpression t = toSExpression t 0 <> "\n"
1414

1515

16+
nl :: Int -> Builder
17+
nl n | n <= 0 = ""
18+
| otherwise = "\n"
19+
20+
pad :: Int -> Builder
21+
pad n = stringUtf8 (replicate (2 * n) ' ')
22+
23+
1624
class ToSExpression t where
1725
toSExpression :: t -> Int -> Builder
1826

@@ -33,7 +41,7 @@ instance Show t => ToSExpressionWithStrategy 'Show t where
3341
toSExpressionWithStrategy _ t _ = stringUtf8 (show t)
3442

3543
instance (Generic t, GToSExpression (Rep t)) => ToSExpressionWithStrategy 'Generic t where
36-
toSExpressionWithStrategy _ t n = "(" <> fold (intersperse " " (gtoSExpression (from t) n)) <> ")"
44+
toSExpressionWithStrategy _ t n = nl n <> pad n <> "(" <> fold (intersperse " " (gtoSExpression (from t) n)) <> ")"
3745

3846

3947
class GToSExpression f where

0 commit comments

Comments
 (0)