1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

Indent/newline.

This commit is contained in:
Rob Rix 2019-06-19 16:03:01 -04:00
parent 1a1bfc3ca7
commit 610acb7380
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -13,6 +13,14 @@ serializeSExpression :: ToSExpression t => t -> Builder
serializeSExpression t = toSExpression t 0 <> "\n"
nl :: Int -> Builder
nl n | n <= 0 = ""
| otherwise = "\n"
pad :: Int -> Builder
pad n = stringUtf8 (replicate (2 * n) ' ')
class ToSExpression t where
toSExpression :: t -> Int -> Builder
@ -33,7 +41,7 @@ instance Show t => ToSExpressionWithStrategy 'Show t where
toSExpressionWithStrategy _ t _ = stringUtf8 (show t)
instance (Generic t, GToSExpression (Rep t)) => ToSExpressionWithStrategy 'Generic t where
toSExpressionWithStrategy _ t n = "(" <> fold (intersperse " " (gtoSExpression (from t) n)) <> ")"
toSExpressionWithStrategy _ t n = nl n <> pad n <> "(" <> fold (intersperse " " (gtoSExpression (from t) n)) <> ")"
class GToSExpression f where