mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Replace the spread function with an extension method.
This commit is contained in:
parent
28d66524bf
commit
d0b6617ce6
@ -68,10 +68,6 @@ public enum Doc: CustomDocConvertible, Equatable {
|
||||
return group(Concat(Text(l), Concat(Nest(2, Concat(Line, x)), Concat(Line, Text(r)))))
|
||||
}
|
||||
|
||||
public static func spread<C: CollectionType where C.Generator.Element == Doc>(docs: C) -> Doc {
|
||||
return docs.fold(<+>)
|
||||
}
|
||||
|
||||
public static func stack<C: CollectionType where C.Generator.Element == Doc>(docs: C) -> Doc {
|
||||
return docs.fold(</>)
|
||||
}
|
||||
@ -118,6 +114,11 @@ extension SequenceType where Generator.Element == Doc {
|
||||
}
|
||||
return fold(Stream(sequence: self))
|
||||
}
|
||||
|
||||
public func spread() -> Doc {
|
||||
return fold(<+>)
|
||||
}
|
||||
|
||||
public func joinWithSeparator(separator: String) -> Doc {
|
||||
return fold {
|
||||
$0 <> .Text(separator) <+> $1
|
||||
|
@ -194,7 +194,7 @@ public enum Syntax<Payload>: CustomDebugStringConvertible, CustomDocConvertible
|
||||
.stack(body.map(Doc.init))
|
||||
].fold(<>)
|
||||
case let .Assign(n, v):
|
||||
return .spread([ .Text(n), .Text("="), Doc(v) ])
|
||||
return [ .Text(n), .Text("="), Doc(v) ].spread()
|
||||
case let .Variable(n):
|
||||
return .Text(n)
|
||||
case let .Literal(s):
|
||||
|
Loading…
Reference in New Issue
Block a user