From b160288682bea77c03ef245e6fdaba6244c64f34 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 18 Jan 2019 13:56:31 +0100 Subject: Blessings: add Foldable instance --- src/Blessings.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/Blessings.hs b/src/Blessings.hs index 3c6b94f..21fe3d8 100644 --- a/src/Blessings.hs +++ b/src/Blessings.hs @@ -20,6 +20,14 @@ data Blessings a deriving (Eq, Show) +instance Foldable Blessings where + foldMap f = \case + Append t1 t2 -> foldMap f t1 <> foldMap f t2 + Plain s -> f s + SGR _ t -> foldMap f t + Empty -> mempty + + instance Functor Blessings where fmap f = \case Append t1 t2 -> Append (fmap f t1) (fmap f t2) -- cgit v1.2.3