summaryrefslogtreecommitdiffstats
path: root/src/Blessings.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blessings.hs')
-rw-r--r--src/Blessings.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Blessings.hs b/src/Blessings.hs
index 8b55e24..59fc4c8 100644
--- a/src/Blessings.hs
+++ b/src/Blessings.hs
@@ -13,6 +13,7 @@ import Control.Applicative
import Data.Ix (inRange)
import Data.List (genericDrop)
import Data.String
+import Data.Tuple.Extra (both, first, second)
import Data.Word (Word8)
import qualified Prelude
import Prelude hiding (drop, length, take)
@@ -393,6 +394,22 @@ instance (Eq a, Blessable a) => Blessable (Blessings a) where
Empty ->
Empty
+ splitAt n = \case
+ Append t1 t2 ->
+ both normalize $
+ let
+ nt1 = Bless.length t1
+ in
+ if n <= nt1
+ then second (<>t2) $ Bless.splitAt n t1
+ else first (t1<>) $ Bless.splitAt (n - nt1) t2
+ Plain s ->
+ both (normalize . Plain) $ Bless.splitAt n s
+ SGR pm t ->
+ both (normalize . SGR pm) $ Bless.splitAt n t
+ Empty ->
+ (Empty, Empty)
+
intercalate i = \case
[] -> mempty
[t] -> t