From 0d662ade08f088616b9533af1d19e3f3bc0ef854 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 14 Oct 2015 09:43:23 -0400 Subject: [PATCH] Implement `extract` on `Cofree`. --- prototype/Doubt/Cofree.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/prototype/Doubt/Cofree.swift b/prototype/Doubt/Cofree.swift index 7e3378463..864ac8bd5 100644 --- a/prototype/Doubt/Cofree.swift +++ b/prototype/Doubt/Cofree.swift @@ -3,3 +3,15 @@ public enum Cofree { case Unroll(B) } + + +// MARK: - Comonad + +extension Cofree { + var extract: B { + switch self { + case let .Unroll(b): + return b + } + } +}