summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-01-18 13:56:31 +0100
committertv <tv@krebsco.de>2019-01-18 13:56:31 +0100
commitb160288682bea77c03ef245e6fdaba6244c64f34 (patch)
treebb609b0667b043cca02900e9f10d9a46111aafcd
parent99a76f167ac7f7814284ec592ff28152b1c85acf (diff)
Blessings: add Foldable instancev1.3.0
-rw-r--r--src/Blessings.hs8
1 files changed, 8 insertions, 0 deletions
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)