streamly icon indicating copy to clipboard operation
streamly copied to clipboard

Add chainl1 to the ParserK module

Open harendra-kumar opened this issue 2 years ago • 0 comments

{-# INLINE chainl1 #-}
chainl1 :: ParserK b IO a -> ParserK b IO (a -> a -> a) -> ParserK b IO a
chainl1 p op = p >>= go

    where

    go l =
        step l <|> pure l
    step l = do
        c <- op
        r <- p
        go (c l r)

harendra-kumar avatar Mar 06 '23 07:03 harendra-kumar