From 95cc7e77681e784ac560afcd3ef9b7a6cb0b1993 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 23 Oct 2015 20:27:12 -0400 Subject: [PATCH] Diff catamorphisms. --- prototype/UI/index.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prototype/UI/index.html b/prototype/UI/index.html index 67a8a1a4b..bca32dcc4 100644 --- a/prototype/UI/index.html +++ b/prototype/UI/index.html @@ -211,6 +211,14 @@ }); } } + + // forall a. Diff a -> (Syntax a -> a) -> a + Diff.prototype.cata = function(transform) { + if (this.pure != null) { return this.pure; } + if (this.roll != null) { + return transform(this.roll.unwrap.map(function(diff) { return diff.cata(transform); })) + } + }