Skip to content

Commit

Permalink
Be strict in the parser state (#39)
Browse files Browse the repository at this point in the history
Improves parseNext. parseFoldr was fine but no harm in being explicit.
  • Loading branch information
meooow25 authored Dec 25, 2024
1 parent dd2096a commit 1b2c2a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Regex/Internal/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ type Foldr f a = forall b. (a -> b -> b) -> b -> f -> b
parseFoldr :: Foldr f c -> Parser c a -> f -> Maybe a
parseFoldr fr = \p xs -> prepareParser p >>= fr f finishParser xs
where
f c k = X.oneShot (\ps -> stepParser ps c >>= k)
f c k = X.oneShot (\ !ps -> stepParser ps c >>= k)
{-# INLINE parseFoldr #-}

-- | \(O(mn \log m)\). Run a parser given a \"@next@\" action.
Expand Down Expand Up @@ -460,7 +460,7 @@ parseNext p next = case prepareParser p of
Nothing -> pure Nothing
Just ps -> loop ps
where
loop ps = next >>= \m -> case m of
loop !ps = next >>= \m -> case m of
Nothing -> pure (finishParser ps)
Just c -> case stepParser ps c of
Nothing -> pure Nothing
Expand Down

0 comments on commit 1b2c2a3

Please sign in to comment.