diff --git a/prototype/Doubt/Stream.swift b/prototype/Doubt/Stream.swift index eeb57611c..f79da6a20 100644 --- a/prototype/Doubt/Stream.swift +++ b/prototype/Doubt/Stream.swift @@ -63,6 +63,13 @@ public enum Stream: NilLiteralConvertible, SequenceType { } + public func fold(initial: Result, combine: (A, Memo) -> Result) -> Result { + return analysis( + ifCons: { combine($0, $1.map { $0.fold(initial, combine: combine) }) }, + ifNil: const(initial)) + } + + public init(nilLiteral: ()) { self = .Nil }