Copyright | (c) 2014 Alp Mestanogullari |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Test.Hspec.Attoparsec.Source
Description
A Source
class that ties parser types and input types to
give you a uniform interface for testing your parsers,
without caring about the input type.
Documentation
class (Eq string, Show string, IsString string) => Source (parser :: Type -> Type -> Type) string string' (result :: Type -> Type) | string -> parser, string -> result, string -> string' where Source #
A 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.
Methods
(~>) :: string -> parser string' a -> Either String a Source #
Feed 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 a Source #
Feed 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.
Instances
Source Parser ByteString ByteString Result Source # | |
Defined in Test.Hspec.Attoparsec.Source Methods (~>) :: ByteString -> Parser ByteString a -> Either String a Source # (~?>) :: ByteString -> Parser ByteString a -> Result a Source # | |
Source Parser ByteString ByteString Result Source # | |
Defined in Test.Hspec.Attoparsec.Source Methods (~>) :: ByteString -> Parser ByteString a -> Either String a Source # (~?>) :: ByteString -> Parser ByteString a -> Result a Source # | |
Source Parser Text Text Result Source # | |
Source Parser Text Text Result Source # | |
class Leftover (r :: Type -> Type) s | r -> s where Source #
Class for generically inspecting unconsumed input
Methods
leftover :: r a -> Maybe s Source #
Get the unconsumed input from the result of a parser
Returns Nothing
if the unconsumed input is ""