avoid unncessary nested lists for combineing StringContainingQuotedPath

This commit is contained in:
Joey Hess 2023-04-09 12:53:13 -04:00
parent 2ba1559a8e
commit 1c21ce17d4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -70,20 +70,20 @@ instance Quoteable RawFilePath where
data StringContainingQuotedPath
= UnquotedString String
| QuotedPath RawFilePath
| StringContainingQuotedPathMulti [StringContainingQuotedPath]
| StringContainingQuotedPath :+: StringContainingQuotedPath
deriving (Show, Eq)
instance Quoteable StringContainingQuotedPath where
quote _ (UnquotedString s) = encodeBS s
quote qp (QuotedPath p) = quote qp p
quote qp (StringContainingQuotedPathMulti l) = S.concat (map (quote qp) l)
quote qp (a :+: b) = quote qp a <> quote qp b
instance IsString StringContainingQuotedPath where
fromString = UnquotedString
instance Sem.Semigroup StringContainingQuotedPath where
UnquotedString a <> UnquotedString b = UnquotedString (a <> b)
a <> b = StringContainingQuotedPathMulti [a, b]
a <> b = a :+: b
instance Monoid StringContainingQuotedPath where
mempty = UnquotedString mempty