1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

CofreeType.cata rethrows errors.

This commit is contained in:
Rob Rix 2015-11-03 10:39:42 -05:00
parent e4e57932cf
commit 1442bc6cf7

View File

@ -124,8 +124,8 @@ extension CofreeType {
/// Catamorphism over `TermType`s.
///
/// Folds the tree encoded by the receiver into a single value by recurring top-down through the tree, applying `transform` to leaves, then to branches, and so forth.
public func cata<Result>(transform: (Annotation, Syntax<Result, Leaf>) -> Result) -> Result {
return self |> (Self.eliminate >>> { ($0, $1.map { $0.cata(transform) }) } >>> transform)
public func cata<Result>(transform: (Annotation, Syntax<Result, Leaf>) throws -> Result) rethrows -> Result {
return try transform(extract, unwrap.map { try $0.cata(transform) })
}