Copyright | © 2019–present Megaparsec contributors |
---|---|
License | FreeBSD |
Maintainer | Mark Karpov <markkarpov92@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Ad-hoc helpers used in Megaparsec's test suite.
Synopsis
- type Parser = Parsec Void String
- prs :: Parser a -> String -> Either (ParseErrorBundle String Void) a
- prs' :: Parser a -> String -> (State String Void, Either (ParseErrorBundle String Void) a)
- prs_ :: Parser a -> String -> Either (ParseErrorBundle String Void) a
- grs :: (forall m. MonadParsec Void String m => m a) -> String -> (Either (ParseErrorBundle String Void) a -> Expectation) -> Expectation
- grs' :: (forall m. MonadParsec Void String m => m a) -> String -> ((State String Void, Either (ParseErrorBundle String Void) a) -> Expectation) -> Expectation
- nes :: a -> NonEmpty a
- abcRow :: Int -> Int -> Int -> String
- rightOrder :: Parser String -> String -> String -> Spec
- scaleDown :: Gen a -> Gen a
- getTabWidth :: MonadParsec e s m => m Pos
- setTabWidth :: MonadParsec e s m => Pos -> m ()
- strSourcePos :: Pos -> SourcePos -> String -> SourcePos
- toChar :: Word8 -> Char
- fromChar :: Char -> Maybe Word8
- sproxy :: Proxy String
- bproxy :: Proxy ByteString
- blproxy :: Proxy ByteString
- tproxy :: Proxy Text
- tlproxy :: Proxy Text
Types
Helpers to run parsers
:: Parser a | Parser to run |
-> String | Input for the parser |
-> Either (ParseErrorBundle String Void) a | Result of parsing |
Apply parser to given input. This is a specialized version of parse
that assumes empty file name.
:: Parser a | Parser to run |
-> String | Input for the parser |
-> (State String Void, Either (ParseErrorBundle String Void) a) | Result of parsing |
Just like prs
, but allows to inspect the final state of the parser.
:: (forall m. MonadParsec Void String m => m a) | Parser to run |
-> String | Input for the parser |
-> (Either (ParseErrorBundle String Void) a -> Expectation) | How to check result of parsing |
-> Expectation |
Just like prs
, but interprets given parser as various monads (tries
all supported monads transformers in turn).
:: (forall m. MonadParsec Void String m => m a) | Parser to run |
-> String | Input for the parser |
-> ((State String Void, Either (ParseErrorBundle String Void) a) -> Expectation) | How to check result of parsing |
-> Expectation |
Other
abcRow :: Int -> Int -> Int -> String Source #
abcRow a b c
generates string consisting of character “a” repeated
a
times, character “b” repeated b
times, and character “c” repeated
c
times.
Check that the given parser returns the list in the right order.
getTabWidth :: MonadParsec e s m => m Pos Source #
Get tab width from PosState
. Use with care only for testing.
setTabWidth :: MonadParsec e s m => Pos -> m () Source #
Set tab width in PosState
. Use with care only for testing.
Char and byte conversion
Proxies
bproxy :: Proxy ByteString Source #
Orphan instances
Arbitrary Void Source # | |
Arbitrary ByteString Source # | |
arbitrary :: Gen ByteString # shrink :: ByteString -> [ByteString] # | |
Arbitrary ByteString Source # | |
arbitrary :: Gen ByteString # shrink :: ByteString -> [ByteString] # | |
Arbitrary Text Source # | |
Arbitrary Pos Source # | |
Arbitrary SourcePos Source # | |
Arbitrary Text Source # | |
Arbitrary a => Arbitrary (NonEmpty a) Source # | |
Arbitrary t => Arbitrary (ErrorItem t) Source # | |
Arbitrary (ErrorFancy a) Source # | |
arbitrary :: Gen (ErrorFancy a) # shrink :: ErrorFancy a -> [ErrorFancy a] # | |
Arbitrary s => Arbitrary (PosState s) Source # | |
(Arbitrary (Token s), Ord (Token s), Arbitrary e, Ord e) => Arbitrary (ParseError s e) Source # | |
arbitrary :: Gen (ParseError s e) # shrink :: ParseError s e -> [ParseError s e] # | |
Arbitrary s => Arbitrary (State s e) Source # | |