Create an expectation by saying what the result should be. Intended to be used with ~> as follows:
"<!-- foo -->" ~> htmlCommentParser
`shouldParse` TagComment " foo ":: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulehspec-attoparsec-0.1.0.2Haskell2010
Utility functions for testing attoparsec parsers, each one providing
an example of how to use it.
Create an expectation by saying what the result should be. Intended to be used with ~> as follows:
"<!-- foo -->" ~> htmlCommentParser
`shouldParse` TagComment " foo "Create an expectation by saying that the parser should successfully parse a value and that this value should satisfy some predicate.
This can fail if the parsing doesn't succeed or if it succeeds but the value doesn't match the predicate.
">>>" ~> many (char '>')
`parseSatisfies` ((==3) . length)Check that a parser succeeds on some given input
char 'x' `shouldSucceedOn` "x"Check that a parser fails on some given input
char 'x' `shouldFailOn` "a"Checking that the given parser succeeds and yields the given part of the input unconsumed. Intended to be used in conjunction with ~?>
("xa" :: Text) ~?> char 'x'
`leavesUnconsumed` "a"class (Eq string, Show string, IsString string) => Source (parser :: Type -> Type -> Type) string string' (result :: Type -> Type) | string -> parser, string -> result, string -> string' whereA class where each instance will just teach how to get an Either or the specific result type associated to the parser for the given input type.
(~>) :: string -> parser string' a -> Either String aFeed some input to a parser and extract the result as either a failure String or an actually parsed value. Can be read as fed to.
-- "<a ...>" fed to an HTML parser
"<a href=\"/foo\">Go to foo</a>" ~> htmlParser :: Either String a(~?>) :: string -> parser string' a -> result aFeed some input to a parser and extract it as the appropriate result type from that module.
This is not currently useful in the library per se,
but is used in test-suites directly where we generally only deal
with one concrete set of parser, input and result types.
This lets us inspect the result in any way we want, e.g
in conjunction with shouldSatisfy or a custom hspec combinator.
Source Parser ByteString ByteString ResultDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceSource Parser ByteString ByteString ResultDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceSource Parser Text Text ResultDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceSource Parser Text Text ResultDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceClass for generically inspecting unconsumed input
Leftover Result ByteStringDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceLeftover Result ByteStringDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceLeftover Result TextDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.SourceLeftover Result TextDefined in hspec-attoparsec-0.1.0.2 · Test.Hspec.Attoparsec.Source