mirror of
https://github.com/github/semantic.git
synced 2025-01-05 05:58:34 +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"
|
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
|
class ToSExpression t where
|
||||||
toSExpression :: t -> Int -> Builder
|
toSExpression :: t -> Int -> Builder
|
||||||
|
|
||||||
@ -33,7 +41,7 @@ instance Show t => ToSExpressionWithStrategy 'Show t where
|
|||||||
toSExpressionWithStrategy _ t _ = stringUtf8 (show t)
|
toSExpressionWithStrategy _ t _ = stringUtf8 (show t)
|
||||||
|
|
||||||
instance (Generic t, GToSExpression (Rep t)) => ToSExpressionWithStrategy 'Generic t where
|
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
|
class GToSExpression f where
|
||||||
|
Loading…
Reference in New Issue
Block a user