@@ -970,6 +970,10 @@ catMaybes = filter isJust . map fromJust
970-- Parsing
970-- Parsing
971------------------------------------------------------------------------------
971------------------------------------------------------------------------------
973+-- Required to fuse "take" with "many" in "chunksOf", for ghc-9.x
974+{-# ANN type Tuple'Fused Fuse #-}
975+data Tuple'Fused a b = Tuple'Fused !a !b deriving Show
973-- | Take at most @n@ input elements and fold them using the supplied fold. A
977-- | Take at most @n@ input elements and fold them using the supplied fold. A
974-- negative count is treated as 0.
978-- negative count is treated as 0.
@@ -988,22 +992,22 @@ take n (Fold fstep finitial fextract) = Fold step initial extract
988 case res of
992 case res of
989 Partial s ->
993 Partial s ->
991− then return $ Partial $ Tuple' 0 s
995+ then return $ Partial $ Tuple'Fused 0 s
992 else Done <$> fextract s
996 else Done <$> fextract s
993 Done b -> return $ Done b
997 Done b -> return $ Done b
995− step (Tuple' i r) a = do
999+ step (Tuple'Fused i r) a = do
996 res <- fstep r a
1000 res <- fstep r a
997 case res of
1001 case res of
998 Partial sres -> do
1002 Partial sres -> do
999 let i1 = i + 1
1003 let i1 = i + 1
1000− s1 = Tuple' i1 sres
1004+ s1 = Tuple'Fused i1 sres
1001 if i1 < n
1005 if i1 < n
1002 then return $ Partial s1
1006 then return $ Partial s1
1003 else Done <$> fextract sres
1007 else Done <$> fextract sres
1004 Done bres -> return $ Done bres
1008 Done bres -> return $ Done bres
1006− extract (Tuple' _ r) = fextract r
1010+ extract (Tuple'Fused _ r) = fextract r
1008------------------------------------------------------------------------------
1012------------------------------------------------------------------------------
1009-- Nesting
1013-- Nesting