From 4195edc469723ab4afad70c621298438846f172e Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 22 Oct 2015 17:25:58 -0400 Subject: [PATCH] Define a `reiterate` function. --- prototype/Doubt/Free.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prototype/Doubt/Free.swift b/prototype/Doubt/Free.swift index 6a5d0c4aa..e9bc00462 100644 --- a/prototype/Doubt/Free.swift +++ b/prototype/Doubt/Free.swift @@ -126,6 +126,11 @@ public func hylo(down: Syntax -> B, _ up: A -> Syntax>> { $0.map(hylo(down, up)) } >>> down } +public func reiterate(down: (Annotation, Syntax) -> B, _ up: A -> (Annotation, Syntax)) -> A -> B { + return up >>> { ($0, $1.map(reiterate(down, up))) } >>> down +} + + extension Free where Value: PatchType, Value.Element == Cofree { public typealias Term = Value.Element