mirror of
https://github.com/github/semantic.git
synced 2025-01-02 20:41:38 +03:00
Indent/newline.
This commit is contained in:
parent
1a1bfc3ca7
commit
610acb7380
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user