summaryrefslogtreecommitdiffstats
path: root/src/Blessings.hs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-03-11 03:41:20 +0100
committertv <tv@krebsco.de>2026-03-15 01:30:13 +0100
commit2e33bc5ac86c81f0c9ee823b4913bce776ba5a0d (patch)
tree546916e3074163508a3f8a02f5196d552802d070 /src/Blessings.hs
parentf4930a40e3ae7af4c43c78f7062d34385153a891 (diff)
add Seq2 Blessings Text split2HEADmaster
Diffstat (limited to 'src/Blessings.hs')
-rw-r--r--src/Blessings.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Blessings.hs b/src/Blessings.hs
index 67eecad..e860b1d 100644
--- a/src/Blessings.hs
+++ b/src/Blessings.hs
@@ -35,6 +35,15 @@ data Blessings a
deriving (Eq, Show)
+cataBlessings :: Monoid a => (a -> r) -> (Pm -> r -> r) -> (r -> r -> r) -> Blessings a -> r
+cataBlessings plain sgr append = go
+ where
+ go (Plain s) = plain s
+ go (SGR pm t) = sgr pm (go t)
+ go (Append t1 t2) = append (go t1) (go t2)
+ go Empty = plain mempty
+
+
instance Foldable Blessings where
foldMap f = \case
Append t1 t2 -> foldMap f t1 <> foldMap f t2