diff --git a/prototype/Doubt/Free.swift b/prototype/Doubt/Free.swift index b657ff8cb..5784fb856 100644 --- a/prototype/Doubt/Free.swift +++ b/prototype/Doubt/Free.swift @@ -217,14 +217,17 @@ public func == (left: extension Free { public func JSON(pure pure: Value -> Doubt.JSON, leaf: Leaf -> Doubt.JSON, annotation: Annotation -> Doubt.JSON) -> Doubt.JSON { - return analysis( - ifPure: { [ "pure": pure($0) ] }, - ifRoll: { - [ "roll": [ - "extract": annotation($0), - "unwrap": $1.JSON(leaf: leaf, recur: { $0.JSON(pure: pure, leaf: leaf, annotation: annotation) }) - ] ] - }) + switch self { + case let .Pure(a): + return [ "pure": pure(a) ] + case let .Roll(a, b): + return [ + "roll": [ + "extract": annotation(a), + "unwrap": b.JSON(leaf: leaf, recur: { $0.JSON(pure: pure, leaf: leaf, annotation: annotation) }) + ] + ] + } } }