From 961e9ae7d76a068017d079b0b08847d3284c8336 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 14 Oct 2015 10:39:01 -0400 Subject: [PATCH] Implement coiteration. --- prototype/Doubt/Cofree.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prototype/Doubt/Cofree.swift b/prototype/Doubt/Cofree.swift index e875dfad9..e774e8a46 100644 --- a/prototype/Doubt/Cofree.swift +++ b/prototype/Doubt/Cofree.swift @@ -14,6 +14,11 @@ public enum Cofree { return rest } } + + + public static func coiterate(annotate: B -> Syntax)(_ seed: B) -> Cofree { + return .Unroll(seed, annotate(seed).map(coiterate(annotate))) + } }