1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

Free.cata’s argument does not escape.

This commit is contained in:
Rob Rix 2015-10-28 11:53:47 -04:00
parent d4aaf2eb55
commit 11a2d2700a

View File

@ -56,10 +56,10 @@ public enum Free<Leaf, Annotation, Value>: CustomDebugStringConvertible {
/// While not every function on a given `Free` can be computed using `cata`, these guarantees of termination and complexity, as well as the brevity and focus on the operation being performed n times, make it a desirable scaffolding for any function which can.
///
/// For a lucid, in-depth tutorial on recursion schemes, I recommend [Patrick Thomson](https://twitter.com/importantshock)s _[An Introduction to Recursion Schemes](http://patrickthomson.ghost.io/an-introduction-to-recursion-schemes/)_ and _[Recursion Schemes, Part 2: A Mob of Morphisms](http://patrickthomson.ghost.io/recursion-schemes-part-2/)_.
public func cata(transform: Syntax<Value, Leaf> -> Value) -> Value {
public func cata(@noescape transform: Syntax<Value, Leaf> -> Value) -> Value {
return analysis(
ifPure: id,
ifRoll: { $1.map { $0.cata(transform) } } >>> transform)
ifRoll: { transform($1.map { $0.cata(transform) }) })
}