From c905ac89274c42bbf545cabf649bd4bbe777a840 Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Sun, 17 Mar 2024 11:52:23 +0100 Subject: [PATCH] Use Int to count chunks in inits --- src/Data/Text/Lazy.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Text/Lazy.hs b/src/Data/Text/Lazy.hs index 9e857cf0..2fc2ff18 100644 --- a/src/Data/Text/Lazy.hs +++ b/src/Data/Text/Lazy.hs @@ -205,7 +205,7 @@ module Data.Text.Lazy -- , sort ) where -import Prelude (Char, Bool(..), Maybe(..), String, +import Prelude (Char, Bool(..), Int, Maybe(..), String, Eq, (==), Ord(..), Ordering(..), Read(..), Show(..), Monad(..), pure, (<$>), (&&), (+), (-), (.), ($), (++), @@ -1445,14 +1445,14 @@ inits = (NE.toList P.$!) . initsNE initsNE :: Text -> NonEmpty Text initsNE ts0 = Empty NE.:| inits' 0 ts0 where - inits' :: Int64 -- Number of previous chunks i + inits' :: Int -- Number of previous chunks i -> Text -- The remainder after dropping i chunks from ts0 -> [Text] -- Prefixes longer than the first i chunks of ts0. inits' !i (Chunk t ts) = L.map (takeChunks i ts0) (NE.tail (T.initsNE t)) ++ inits' (i + 1) ts inits' _ Empty = [] -takeChunks :: Int64 -> Text -> T.Text -> Text +takeChunks :: Int -> Text -> T.Text -> Text takeChunks !i (Chunk t ts) lastChunk | i > 0 = Chunk t (takeChunks (i - 1) ts lastChunk) takeChunks _ _ lastChunk = Chunk lastChunk Empty