summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-03-08 04:48:45 +0100
committertv <tv@krebsco.de>2026-03-08 04:48:45 +0100
commit3c9c9e5f2d9cee8f33d7ba333fb7995c0b7f91ec (patch)
tree8b6d93ac38838a47403ee9f08f4b0cb39d6ddf09
parentae9f49e0a6e7d5a0c906d8e4fd153ad553cdecf1 (diff)
decouple structural operations from normalization
-rw-r--r--src/Blessings.hs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/Blessings.hs b/src/Blessings.hs
index 3ee32a2..dba5e77 100644
--- a/src/Blessings.hs
+++ b/src/Blessings.hs
@@ -447,11 +447,11 @@ instance Blessable a => IsSequence (Blessings a) where
t1' = S.drop n1 t1
t2' = S.drop n2 t2
in
- normalizeHead $ Append t1' t2'
+ Append t1' t2'
Plain s ->
- normalizeHead $ Plain (S.drop n s)
+ Plain (S.drop n s)
SGR pm t ->
- normalizeHead $ SGR pm (S.drop n t)
+ SGR pm (S.drop n t)
Empty ->
Empty
@@ -461,20 +461,18 @@ instance Blessable a => IsSequence (Blessings a) where
t1' = S.take n t1
n' = n - S.lengthIndex t1'
in
- normalizeHead $
if n' > 0
then t1' <> S.take n' t2
else t1'
Plain s ->
- normalizeHead $ Plain (S.take n s)
+ Plain (S.take n s)
SGR pm t ->
- normalizeHead $ SGR pm (S.take n t)
+ SGR pm (S.take n t)
Empty ->
Empty
splitAt n = \case
Append t1 t2 ->
- both normalizeHead $
let
nt1 = S.lengthIndex t1
in
@@ -482,15 +480,14 @@ instance Blessable a => IsSequence (Blessings a) where
then second (<>t2) $ S.splitAt n t1
else first (t1<>) $ S.splitAt (n - nt1) t2
Plain s ->
- both (normalizeHead . Plain) $ S.splitAt n s
+ both Plain $ S.splitAt n s
SGR pm t ->
- both (normalizeHead . SGR pm) $ S.splitAt n t
+ both (SGR pm) $ S.splitAt n t
Empty ->
(Empty, Empty)
break p = \case
Append t1 t2 ->
- both normalizeHead $
case S.break p t1 of
(t1l, t1r)
| t1r == mempty -> first (t1l<>) $ S.break p t2
@@ -499,7 +496,7 @@ instance Blessable a => IsSequence (Blessings a) where
| p s -> (Empty, Plain s)
| otherwise -> (Plain s, Empty)
SGR pm t ->
- both (normalizeHead . SGR pm) $ S.break p t
+ both (SGR pm) $ S.break p t
Empty ->
(Empty, Empty)