1
1
mirror of https://github.com/github/semantic.git synced 2024-12-28 09:21:35 +03:00

Don’t print L1/R1.

This commit is contained in:
Rob Rix 2019-10-03 02:50:42 -04:00
parent 70b24a476d
commit 867a65c575
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -28,14 +28,19 @@ instance (ToSExpressionBy strategy t, strategy ~ ToSExpressionStrategy t) => ToS
toSExpression = toSExpression' @strategy
data Strategy = Generic
data Strategy = Generic | Custom
type family ToSExpressionStrategy (t :: * -> *) :: Strategy where
ToSExpressionStrategy _ = 'Generic
ToSExpressionStrategy (_ :+: _) = 'Custom
ToSExpressionStrategy _ = 'Generic
class ToSExpressionBy (strategy :: Strategy) t where
toSExpression' :: t ann -> Int -> Builder
instance (ToSExpression l, ToSExpression r) => ToSExpressionBy 'Custom (l :+: r) where
toSExpression' (L1 l) = toSExpression l
toSExpression' (R1 r) = toSExpression r
instance (Generic1 t, GToSExpression (Rep1 t)) => ToSExpressionBy 'Generic t where
toSExpression' t n = nl n <> pad n <> "(" <> fold (intersperse " " (gtoSExpression (from1 t) n)) <> ")"