-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Utility functions for testing Megaparsec parsers with Hspec
--   
--   Utility functions for testing Megaparsec parsers with Hspec.
@package hspec-megaparsec
@version 0.3.1


-- | Utility functions for testing Megaparsec parsers with Hspec.
module Test.Hspec.Megaparsec

-- | Create an expectation by saying what the result should be.
--   
--   <pre>
--   parse letterChar "" "x" `shouldParse` 'x'
--   </pre>
shouldParse :: (Ord t, ShowToken t, ShowErrorComponent e, Eq a, Show a) => Either (ParseError t e) a -> a -> Expectation

-- | Create an expectation by saying that the parser should successfully
--   parse a value and that the value should satisfy some predicate.
--   
--   <pre>
--   parse (many punctuationChar) "" "?!!" `parseSatisfies` ((== 3) . length)
--   </pre>
parseSatisfies :: (Ord t, ShowToken t, ShowErrorComponent e, Show a) => Either (ParseError t e) a -> (a -> Bool) -> Expectation

-- | Check that a parser succeeds on some given input.
--   
--   <pre>
--   parse (char 'x') "" `shouldSucceedOn` "x"
--   </pre>
shouldSucceedOn :: (Ord t, ShowToken t, ShowErrorComponent e, Show a) => (s -> Either (ParseError t e) a) -> s -> Expectation

-- | Check that a parser fails on some given input.
--   
--   <pre>
--   parse (char 'x') "" `shouldFailOn` "a"
--   </pre>
shouldFailOn :: Show a => (s -> Either (ParseError t e) a) -> s -> Expectation

-- | Create an expectation that parser should fail producing certain
--   <a>ParseError</a>. Use the <a>err</a> function from this module to
--   construct a <a>ParseError</a> to compare with.
--   
--   <pre>
--   parse (char 'x') "" "b" `shouldFailWith` err posI (utok 'b' &lt;&gt; etok 'x')
--   </pre>
shouldFailWith :: (Ord t, ShowToken t, ShowErrorComponent e, Show a) => Either (ParseError t e) a -> ParseError t e -> Expectation

-- | Assemble a <tt>ParseErorr</tt> from source position and <tt><a>EC</a>
--   t e</tt> value. To create source position, two helpers are available:
--   <a>posI</a> and <a>posN</a>. <tt><a>EC</a> t e</tt> is a monoid and
--   can be built from primitives provided by this module, see below.
err :: NonEmpty SourcePos -> EC t e -> ParseError t e

-- | Initial source position with empty file name.
posI :: NonEmpty SourcePos

-- | <tt>posN n s</tt> returns source position achieved by applying
--   <a>updatePos</a> method corresponding to type of stream <tt>s</tt>
--   <tt>n</tt> times.
posN :: forall s n. (Stream s, Integral n) => n -> s -> NonEmpty SourcePos

-- | Auxiliary type for construction of <a>ParseError</a>s. Note that it's
--   a monoid.
data EC t e

-- | Construct “unexpected token” error component.
utok :: (Ord t, Ord e) => t -> EC t e

-- | Construct “unexpected tokens” error component. Empty string produces
--   <a>EndOfInput</a>.
utoks :: (Ord t, Ord e) => [t] -> EC t e

-- | Construct “unexpected label” error component. Do not use with empty
--   strings (for empty strings it's bottom).
ulabel :: (Ord t, Ord e) => String -> EC t e

-- | Construct “unexpected end of input” error component.
ueof :: (Ord t, Ord e) => EC t e

-- | Construct “expected token” error component.
etok :: (Ord t, Ord e) => t -> EC t e

-- | Construct “expected tokens” error component. Empty string produces
--   <a>EndOfInput</a>.
etoks :: (Ord t, Ord e) => [t] -> EC t e

-- | Construct “expected label” error component. Do not use with empty
--   strings.
elabel :: (Ord t, Ord e) => String -> EC t e

-- | Construct “expected end of input” error component.
eeof :: (Ord t, Ord e) => EC t e

-- | Construct custom error component.
cstm :: e -> EC t e

-- | Check that a parser fails and leaves certain part of input unconsumed.
--   Use it with functions like <a>runParser'</a> and <a>runParserT'</a>
--   that support incremental parsing.
--   
--   <pre>
--   runParser' (many (char 'x') &lt;* eof) (initialState "xxa")
--     `failsLeaving` "a"
--   </pre>
--   
--   See also: <a>initialState</a>.
failsLeaving :: (Show a, Eq s, Show s, Stream s) => (State s, Either (ParseError (Token s) e) a) -> s -> Expectation

-- | Check that a parser succeeds and leaves certain part of input
--   unconsumed. Use it with functions like <a>runParser'</a> and
--   <a>runParserT'</a> that support incremental parsing.
--   
--   <pre>
--   runParser' (many (char 'x')) (initialState "xxa")
--     `succeedsLeaving` "a"
--   </pre>
--   
--   See also: <a>initialState</a>.
succeedsLeaving :: (ShowToken (Token s), ShowErrorComponent e, Show a, Eq s, Show s, Stream s) => (State s, Either (ParseError (Token s) e) a) -> s -> Expectation

-- | Given input for parsing, construct initial state for parser (that is,
--   with empty file name, default tab width and position at 1 line and 1
--   column).
initialState :: s -> State s
instance GHC.Generics.Generic (Test.Hspec.Megaparsec.EC t e)
instance (GHC.Classes.Ord e, GHC.Classes.Ord t, Data.Data.Data e, Data.Data.Data t) => Data.Data.Data (Test.Hspec.Megaparsec.EC t e)
instance (GHC.Classes.Eq e, GHC.Classes.Eq t) => GHC.Classes.Eq (Test.Hspec.Megaparsec.EC t e)
instance (GHC.Classes.Ord t, GHC.Classes.Ord e) => Data.Semigroup.Semigroup (Test.Hspec.Megaparsec.EC t e)
instance (GHC.Classes.Ord t, GHC.Classes.Ord e) => GHC.Base.Monoid (Test.Hspec.Megaparsec.EC t e)
