From f816c9028c678035b61c929c84b048067c2da027 Mon Sep 17 00:00:00 2001 From: Jaro Date: Tue, 9 May 2023 01:50:13 +0200 Subject: [PATCH] Allow extracting ResolvedBox from WithSpan. --- src/Data/Text/ParagraphLayout/Internal/WithSpan.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Data/Text/ParagraphLayout/Internal/WithSpan.hs b/src/Data/Text/ParagraphLayout/Internal/WithSpan.hs index b946fa4..e9b7f0a 100644 --- a/src/Data/Text/ParagraphLayout/Internal/WithSpan.hs +++ b/src/Data/Text/ParagraphLayout/Internal/WithSpan.hs @@ -1,7 +1,11 @@ -module Data.Text.ParagraphLayout.Internal.WithSpan (WithSpan (WithSpan)) +module Data.Text.ParagraphLayout.Internal.WithSpan + ( WithSpan (WithSpan) + , allBoxes + ) where import Data.Text.ParagraphLayout.Internal.BiDiReorder +import Data.Text.ParagraphLayout.Internal.ResolvedBox import Data.Text.ParagraphLayout.Internal.ResolvedSpan import Data.Text.ParagraphLayout.Internal.TextContainer @@ -22,3 +26,9 @@ instance SeparableTextContainer a => SeparableTextContainer (WithSpan d a) where instance WithLevel a => WithLevel (WithSpan d a) where level (WithSpan _ x) = level x + +boxes :: WithSpan d a -> [ResolvedBox d] +boxes (WithSpan s _) = spanBoxes s + +allBoxes :: (Foldable f, Functor f) => f (WithSpan d a) -> [ResolvedBox d] +allBoxes xs = foldr union [] $ fmap boxes xs -- 2.30.2