From 3c9c9e5f2d9cee8f33d7ba333fb7995c0b7f91ec Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Mar 2026 04:48:45 +0100 Subject: decouple structural operations from normalization --- src/Blessings.hs | 19 ++++++++----------- 1 file 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) -- cgit v1.2.3