module Data.Text.ParagraphLayout.Internal.WithSpan (WithSpan (WithSpan))
where
import Data.Text.ParagraphLayout.Internal.BiDiReorder
import Data.Text.ParagraphLayout.Internal.ResolvedSpan
import Data.Text.ParagraphLayout.Internal.TextContainer
-- | Wrapper for temporarily mapping the relationship to a `ResolvedSpan`.
data WithSpan d a = WithSpan (ResolvedSpan d) a
instance Functor (WithSpan d) where
fmap f (WithSpan s a) = WithSpan s (f a)
instance TextContainer a => TextContainer (WithSpan d a) where
getText (WithSpan _ c) = getText c
instance SeparableTextContainer a => SeparableTextContainer (WithSpan d a) where
splitTextAt8 n (WithSpan rs c) = (WithSpan rs c1, WithSpan rs c2)
where (c1, c2) = splitTextAt8 n c
dropWhileStart p (WithSpan rs c) = WithSpan rs (dropWhileStart p c)
dropWhileEnd p (WithSpan rs c) = WithSpan rs (dropWhileEnd p c)
instance WithLevel a => WithLevel (WithSpan d a) where
level (WithSpan _ x) = level x