streamly-0.7.2: Beautiful Streaming, Concurrent and Reactive Composition

Copyright(c) 2020 Composewell Technologies
LicenseBSD3
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Data.Parser.Tee

Description

Parallel parsers. Distributing the input to multiple parsers at the same time.

For simplicity, we are using code where a particular state is unreachable but it is not prevented by types. Somehow uni-pattern match using "let" produces better optimized code compared to using case match and using explicit error messages in unreachable cases.

There seem to be no way to silence individual warnings so we use a global incomplete uni-pattern match warning suppression option for the file. Disabling the warning for other code as well has the potential to mask off some legit warnings, therefore, we have segregated only the code that uses uni-pattern matches in this module.

Synopsis

Documentation

teeWith :: Monad m => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c Source #

teeWith f p1 p2 distributes its input to both p1 and p2 until both of them succeed or fail and combines their output using f. The parser succeeds if both the parsers succeed.

Internal

teeWithFst :: Monad m => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c Source #

Like teeWith but ends parsing and zips the results, if available, whenever the first parser ends.

Internal

teeWithMin :: (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c Source #

Like teeWith but ends parsing and zips the results, if available, whenever any of the parsers ends or fails.

Unimplemented

shortest :: Monad m => Parser m x a -> Parser m x a -> Parser m x a Source #

Shortest alternative. Apply both parsers in parallel but choose the result from the one which consumed least input i.e. take the shortest succeeding parse.

Internal

longest :: MonadCatch m => Parser m x a -> Parser m x a -> Parser m x a Source #

Longest alternative. Apply both parsers in parallel but choose the result from the one which consumed more input i.e. take the longest succeeding parse.

Internal