We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d330733 commit 8c3f304Copy full SHA for 8c3f304
core/src/Streamly/Internal/Data/ParserK/Type.hs
@@ -32,6 +32,7 @@ module Streamly.Internal.Data.ParserK.Type
32
, fromPure
33
, fromEffect
34
, die
35
+ , chainl1
36
37
, parserDone
38
@@ -538,3 +539,16 @@ toParser parser = ParserD.Parser step initial extract
538
539
forall s. toParser (parserK s) = s #-}
540
{-# RULES "toParser/fromParser fusion" [2]
541
forall s. parserK (toParser s) = s #-}
542
+
543
+{-# INLINE chainl1 #-}
544
+chainl1 :: ParserK b IO a -> ParserK b IO (a -> a -> a) -> ParserK b IO a
545
+chainl1 p op = p >>= go
546
547
+ where
548
549
+ go l = step l <|> pure l
550
551
+ step l = do
552
+ c <- op
553
+ r <- p
554
+ go (c l r)
0 commit comments