-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple parser combinators -- -- Please see the README on GitHub at -- https://github.com/ejconlon/simple-parser#readme @package simple-parser @version 0.10.0 module SimpleParser.Chunked -- | Chunked captures the basic relationship between tokens and -- chunks of them. Basically, these things behave like lists, sequences, -- text, etc. class Monoid chunk => Chunked chunk token | chunk -> token consChunk :: Chunked chunk token => token -> chunk -> chunk unconsChunk :: Chunked chunk token => chunk -> Maybe (token, chunk) tokenToChunk :: Chunked chunk token => token -> chunk tokensToChunk :: Chunked chunk token => [token] -> chunk chunkToTokens :: Chunked chunk token => chunk -> [token] chunkLength :: Chunked chunk token => chunk -> Int chunkEmpty :: Chunked chunk token => chunk -> Bool -- | Some datatypes (like Seq) may admit a "better" implementation -- for building a chunk in reverse. revTokensToChunk :: Chunked chunk token => [token] -> chunk -- | Captures textual streams. class Chunked chunk Char => TextualChunked chunk buildChunk :: TextualChunked chunk => chunk -> Builder packChunk :: TextualChunked chunk => chunk -> Text unpackChunk :: TextualChunked chunk => Text -> chunk instance (a GHC.Types.~ GHC.Types.Char) => SimpleParser.Chunked.TextualChunked [a] instance (a GHC.Types.~ GHC.Types.Char) => SimpleParser.Chunked.TextualChunked (Data.Sequence.Internal.Seq a) instance SimpleParser.Chunked.TextualChunked Data.Text.Internal.Text instance SimpleParser.Chunked.TextualChunked Data.Text.Internal.Lazy.Text instance SimpleParser.Chunked.Chunked [a] a instance SimpleParser.Chunked.Chunked (Data.Sequence.Internal.Seq a) a instance SimpleParser.Chunked.Chunked Data.Text.Internal.Text GHC.Types.Char instance SimpleParser.Chunked.Chunked Data.Text.Internal.Lazy.Text GHC.Types.Char instance SimpleParser.Chunked.Chunked Data.ByteString.Internal.ByteString GHC.Word.Word8 instance SimpleParser.Chunked.Chunked Data.ByteString.Lazy.Internal.ByteString GHC.Word.Word8 module SimpleParser.Stack -- | A stack supporting O(1) push, top, and bottom. Behind the newtype, a -- "push" onto the stack is implemented as "snoc", therefore -- fold/traverse goes from bottom of stack (most generic label) to top -- (most specific label). newtype Stack a Stack :: Seq a -> Stack a [unStack] :: Stack a -> Seq a -- | Easy constructor for the empty stack emptyStack :: Stack a -- | Pushes a an element onto a Stack pushStack :: a -> Stack a -> Stack a -- | Returns the top element of the stack (most recently pushed). topStack :: Stack a -> Maybe a -- | Returns the bottom element of the stack (least recently pushed). bottomStack :: Stack a -> Maybe a -- | Selects elements from the bottom of the stack to the top. bottomUpStack :: (a -> Maybe b) -> Stack a -> Seq b instance Data.Traversable.Traversable SimpleParser.Stack.Stack instance Data.Foldable.Foldable SimpleParser.Stack.Stack instance GHC.Base.Functor SimpleParser.Stack.Stack instance GHC.Show.Show a => GHC.Show.Show (SimpleParser.Stack.Stack a) instance GHC.Classes.Eq a => GHC.Classes.Eq (SimpleParser.Stack.Stack a) -- | This reworks Stream to split interfaces. See -- Text.Megaparsec.Stream. module SimpleParser.Stream -- | Stream lets us peel off tokens and chunks for parsing with -- explicit state passing. class Chunked (Chunk s) (Token s) => Stream s where { type family Chunk s :: Type; type family Token s :: Type; } streamTake1 :: Stream s => s -> Maybe (Token s, s) streamTakeN :: Stream s => Int -> s -> Maybe (Chunk s, s) streamTakeWhile :: Stream s => (Token s -> Bool) -> s -> (Chunk s, s) streamDropN :: Stream s => Int -> s -> Maybe (Int, s) streamDropWhile :: Stream s => (Token s -> Bool) -> s -> (Int, s) type TextualStream s = (Stream s, Token s ~ Char, TextualChunked (Chunk s)) -- | PosStream adds position tracking to a Stream. class Stream s => PosStream s where { type family Pos s :: Type; } streamViewPos :: PosStream s => s -> Pos s newtype Offset Offset :: Int -> Offset [unOffset] :: Offset -> Int -- | Stream wrapper that maintains an offset position. data OffsetStream s OffsetStream :: !Offset -> !s -> OffsetStream s [osOffset] :: OffsetStream s -> !Offset [osState] :: OffsetStream s -> !s newOffsetStream :: s -> OffsetStream s newtype Line Line :: Int -> Line [unLine] :: Line -> Int newtype Col Col :: Int -> Col [unCol] :: Col -> Int -- | A 0-based line/col position in a character-based stream. data LinePos LinePos :: !Offset -> !Line -> !Col -> LinePos [lpOffset] :: LinePos -> !Offset [lpLine] :: LinePos -> !Line [lpCol] :: LinePos -> !Col -- | Stream wrapper that maintains a line/col position. data LinePosStream s LinePosStream :: !LinePos -> !s -> LinePosStream s [lpsLinePos] :: LinePosStream s -> !LinePos [lpsState] :: LinePosStream s -> !s newLinePosStream :: s -> LinePosStream s -- | A range between two positions. data Span p Span :: !p -> !p -> Span p [spanStart] :: Span p -> !p [spanEnd] :: Span p -> !p -- | Allows projections into (Line, Col) for more exotic stream positions. class HasLinePos p viewLine :: HasLinePos p => p -> Line viewCol :: HasLinePos p => p -> Col instance GHC.Real.Integral SimpleParser.Stream.Offset instance GHC.Real.Real SimpleParser.Stream.Offset instance GHC.Num.Num SimpleParser.Stream.Offset instance GHC.Enum.Enum SimpleParser.Stream.Offset instance GHC.Classes.Ord SimpleParser.Stream.Offset instance GHC.Show.Show SimpleParser.Stream.Offset instance GHC.Classes.Eq SimpleParser.Stream.Offset instance Data.Traversable.Traversable SimpleParser.Stream.OffsetStream instance Data.Foldable.Foldable SimpleParser.Stream.OffsetStream instance GHC.Base.Functor SimpleParser.Stream.OffsetStream instance GHC.Show.Show s => GHC.Show.Show (SimpleParser.Stream.OffsetStream s) instance GHC.Classes.Eq s => GHC.Classes.Eq (SimpleParser.Stream.OffsetStream s) instance GHC.Real.Integral SimpleParser.Stream.Line instance GHC.Real.Real SimpleParser.Stream.Line instance GHC.Num.Num SimpleParser.Stream.Line instance GHC.Enum.Enum SimpleParser.Stream.Line instance GHC.Classes.Ord SimpleParser.Stream.Line instance GHC.Show.Show SimpleParser.Stream.Line instance GHC.Classes.Eq SimpleParser.Stream.Line instance GHC.Real.Integral SimpleParser.Stream.Col instance GHC.Real.Real SimpleParser.Stream.Col instance GHC.Num.Num SimpleParser.Stream.Col instance GHC.Enum.Enum SimpleParser.Stream.Col instance GHC.Classes.Ord SimpleParser.Stream.Col instance GHC.Show.Show SimpleParser.Stream.Col instance GHC.Classes.Eq SimpleParser.Stream.Col instance GHC.Classes.Ord SimpleParser.Stream.LinePos instance GHC.Show.Show SimpleParser.Stream.LinePos instance GHC.Classes.Eq SimpleParser.Stream.LinePos instance Data.Traversable.Traversable SimpleParser.Stream.LinePosStream instance Data.Foldable.Foldable SimpleParser.Stream.LinePosStream instance GHC.Base.Functor SimpleParser.Stream.LinePosStream instance GHC.Show.Show s => GHC.Show.Show (SimpleParser.Stream.LinePosStream s) instance GHC.Classes.Eq s => GHC.Classes.Eq (SimpleParser.Stream.LinePosStream s) instance GHC.Classes.Ord p => GHC.Classes.Ord (SimpleParser.Stream.Span p) instance GHC.Show.Show p => GHC.Show.Show (SimpleParser.Stream.Span p) instance GHC.Classes.Eq p => GHC.Classes.Eq (SimpleParser.Stream.Span p) instance SimpleParser.Stream.HasLinePos SimpleParser.Stream.LinePos instance (SimpleParser.Stream.Stream s, SimpleParser.Stream.Token s GHC.Types.~ GHC.Types.Char) => SimpleParser.Stream.Stream (SimpleParser.Stream.LinePosStream s) instance (SimpleParser.Stream.Stream s, SimpleParser.Stream.Token s GHC.Types.~ GHC.Types.Char) => SimpleParser.Stream.PosStream (SimpleParser.Stream.LinePosStream s) instance SimpleParser.Stream.Stream s => SimpleParser.Stream.Stream (SimpleParser.Stream.OffsetStream s) instance SimpleParser.Stream.Stream s => SimpleParser.Stream.PosStream (SimpleParser.Stream.OffsetStream s) instance SimpleParser.Stream.Stream [a] instance SimpleParser.Stream.Stream (Data.Sequence.Internal.Seq a) instance SimpleParser.Stream.Stream Data.Text.Internal.Text instance SimpleParser.Stream.Stream Data.Text.Internal.Lazy.Text instance SimpleParser.Stream.Stream Data.ByteString.Internal.ByteString instance SimpleParser.Stream.Stream Data.ByteString.Lazy.Internal.ByteString module SimpleParser.Result data RawError chunk token RawErrorMatchEnd :: !token -> RawError chunk token RawErrorAnyToken :: RawError chunk token RawErrorAnyChunk :: RawError chunk token RawErrorSatisfyToken :: !Maybe token -> RawError chunk token RawErrorMatchToken :: !token -> !Maybe token -> RawError chunk token RawErrorMatchChunk :: !chunk -> !Maybe chunk -> RawError chunk token RawErrorTakeTokensWhile1 :: !Maybe token -> RawError chunk token RawErrorDropTokensWhile1 :: !Maybe token -> RawError chunk token -- | RawStreamError specialized to Stream types - newtyped -- to allow GHC to derive eq/show in the absense of type families. newtype StreamError s StreamError :: RawError (Chunk s) (Token s) -> StreamError s [unStreamError] :: StreamError s -> RawError (Chunk s) (Token s) coerceStreamError :: (Chunk s ~ Chunk t, Token s ~ Token t) => StreamError s -> StreamError t data CompoundError s e CompoundErrorStream :: !StreamError s -> CompoundError s e CompoundErrorFail :: !Text -> CompoundError s e CompoundErrorCustom :: !e -> CompoundError s e data Mark l s Mark :: !Maybe l -> !s -> Mark l s [markLabel] :: Mark l s -> !Maybe l [markState] :: Mark l s -> !s data ParseError l s e ParseError :: !MarkStack l s -> !s -> !CompoundError s e -> ParseError l s e [peMarkStack] :: ParseError l s e -> !MarkStack l s [peEndState] :: ParseError l s e -> !s [peError] :: ParseError l s e -> !CompoundError s e -- | Returns the resumption point of the ParseError. If it has been -- marked, we use that, otherwise we assume it starts at the exact error -- point. parseErrorResume :: ParseError l s e -> s -- | Returns the sequence of ALL labels from coarsest to finest. parseErrorLabels :: ParseError l s e -> Seq l -- | Updates a ParseError with a resumption point. markParseError :: Mark l s -> ParseError l s e -> ParseError l s e -- | Clears marks from a ParseError. unmarkParseError :: ParseError l s e -> ParseError l s e -- | Returns labels enclosing the narrowest span, from coarsest to finest -- Does NOT include the label for the narrowest span (if any). parseErrorEnclosingLabels :: ParseError l s e -> Seq l -- | Returns the narrowest span parseErrorNarrowestSpan :: PosStream s => ParseError l s e -> (Maybe l, Span (Pos s)) newtype ParseErrorBundle l s e ParseErrorBundle :: NESeq (ParseError l s e) -> ParseErrorBundle l s e [unParseErrorBundle] :: ParseErrorBundle l s e -> NESeq (ParseError l s e) -- | Lists all errors in the bundle. listParseErrors :: ParseErrorBundle l s e -> [ParseError l s e] -- | If there is only one parse error in the bundle, return it, otherwise -- return nothing. Errors can accumulate if you use unrestricted -- branching (with orParser or Alternative -- <|>) or manual Parser constructor application. -- However, if you always branch with lookAheadMatch then you -- will have singleton parse errors, and this will always return -- Just. matchSoleParseError :: ParseErrorBundle l s e -> Maybe (ParseError l s e) data ParseSuccess s a ParseSuccess :: !s -> !a -> ParseSuccess s a [psEndState] :: ParseSuccess s a -> !s [psValue] :: ParseSuccess s a -> !a data ParseResult l s e a ParseResultError :: !ParseErrorBundle l s e -> ParseResult l s e a ParseResultSuccess :: !ParseSuccess s a -> ParseResult l s e a instance (GHC.Show.Show token, GHC.Show.Show chunk) => GHC.Show.Show (SimpleParser.Result.RawError chunk token) instance (GHC.Classes.Eq token, GHC.Classes.Eq chunk) => GHC.Classes.Eq (SimpleParser.Result.RawError chunk token) instance Data.Traversable.Traversable (SimpleParser.Result.CompoundError s) instance Data.Foldable.Foldable (SimpleParser.Result.CompoundError s) instance GHC.Base.Functor (SimpleParser.Result.CompoundError s) instance (GHC.Show.Show l, GHC.Show.Show s) => GHC.Show.Show (SimpleParser.Result.Mark l s) instance (GHC.Classes.Eq l, GHC.Classes.Eq s) => GHC.Classes.Eq (SimpleParser.Result.Mark l s) instance Data.Traversable.Traversable (SimpleParser.Result.ParseSuccess s) instance Data.Foldable.Foldable (SimpleParser.Result.ParseSuccess s) instance GHC.Base.Functor (SimpleParser.Result.ParseSuccess s) instance (GHC.Show.Show s, GHC.Show.Show a) => GHC.Show.Show (SimpleParser.Result.ParseSuccess s a) instance (GHC.Classes.Eq s, GHC.Classes.Eq a) => GHC.Classes.Eq (SimpleParser.Result.ParseSuccess s a) instance Data.Traversable.Traversable (SimpleParser.Result.ParseResult l s e) instance Data.Foldable.Foldable (SimpleParser.Result.ParseResult l s e) instance GHC.Base.Functor (SimpleParser.Result.ParseResult l s e) instance (GHC.Classes.Eq (SimpleParser.Stream.Token s), GHC.Classes.Eq (SimpleParser.Stream.Chunk s)) => GHC.Classes.Eq (SimpleParser.Result.StreamError s) instance (GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s)) => GHC.Show.Show (SimpleParser.Result.StreamError s) instance (GHC.Classes.Eq (SimpleParser.Stream.Token s), GHC.Classes.Eq (SimpleParser.Stream.Chunk s), GHC.Classes.Eq e) => GHC.Classes.Eq (SimpleParser.Result.CompoundError s e) instance (GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s), GHC.Show.Show e) => GHC.Show.Show (SimpleParser.Result.CompoundError s e) instance (GHC.Classes.Eq l, GHC.Classes.Eq s, GHC.Classes.Eq (SimpleParser.Stream.Token s), GHC.Classes.Eq (SimpleParser.Stream.Chunk s), GHC.Classes.Eq e) => GHC.Classes.Eq (SimpleParser.Result.ParseError l s e) instance (GHC.Show.Show l, GHC.Show.Show s, GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s), GHC.Show.Show e) => GHC.Show.Show (SimpleParser.Result.ParseError l s e) instance (GHC.Classes.Eq l, GHC.Classes.Eq s, GHC.Classes.Eq (SimpleParser.Stream.Token s), GHC.Classes.Eq (SimpleParser.Stream.Chunk s), GHC.Classes.Eq e) => GHC.Classes.Eq (SimpleParser.Result.ParseErrorBundle l s e) instance (GHC.Show.Show l, GHC.Show.Show s, GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s), GHC.Show.Show e) => GHC.Show.Show (SimpleParser.Result.ParseErrorBundle l s e) instance (GHC.Classes.Eq l, GHC.Classes.Eq s, GHC.Classes.Eq (SimpleParser.Stream.Token s), GHC.Classes.Eq (SimpleParser.Stream.Chunk s), GHC.Classes.Eq e, GHC.Classes.Eq a) => GHC.Classes.Eq (SimpleParser.Result.ParseResult l s e a) instance (GHC.Show.Show l, GHC.Show.Show s, GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s), GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (SimpleParser.Result.ParseResult l s e a) instance (Data.Typeable.Internal.Typeable l, Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable (SimpleParser.Stream.Token s), Data.Typeable.Internal.Typeable (SimpleParser.Stream.Chunk s), Data.Typeable.Internal.Typeable e, GHC.Show.Show l, GHC.Show.Show s, GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s), GHC.Show.Show e) => GHC.Exception.Type.Exception (SimpleParser.Result.ParseErrorBundle l s e) instance (Data.Typeable.Internal.Typeable l, Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable (SimpleParser.Stream.Token s), Data.Typeable.Internal.Typeable (SimpleParser.Stream.Chunk s), Data.Typeable.Internal.Typeable e, GHC.Show.Show l, GHC.Show.Show s, GHC.Show.Show (SimpleParser.Stream.Token s), GHC.Show.Show (SimpleParser.Stream.Chunk s), GHC.Show.Show e) => GHC.Exception.Type.Exception (SimpleParser.Result.ParseError l s e) -- | ParserT is the core monad transformer for parsing. module SimpleParser.Parser -- | A ParserT is a stateerrorlist transformer useful for -- parsing. All MTL instances are for this transformer only. If, for -- example, your effect has its own MonadState instance, you'll -- have to use 'lift get' instead of get. newtype ParserT l s e m a ParserT :: (s -> m (Maybe (ParseResult l s e a))) -> ParserT l s e m a [runParserT] :: ParserT l s e m a -> s -> m (Maybe (ParseResult l s e a)) -- | Use Parser if you have no need for other monadic effects. type Parser l s e a = ParserT l s e Identity a -- | Runs a non-effectful parser from an inital state and collects all -- results. runParser :: Parser l s e a -> s -> Maybe (ParseResult l s e a) -- | Applicative pure pureParser :: Monad m => a -> ParserT l s e m a -- | Monadic bind bindParser :: Monad m => ParserT l s e m a -> (a -> ParserT l s e m b) -> ParserT l s e m b -- | A simple failing parser failParser :: Monad m => Text -> ParserT l s e m a liftParser :: Monad m => m a -> ParserT l s e m a hoistParser :: (forall x. m x -> n x) -> ParserT l s e m a -> ParserT l s e n a -- | Catch only a subset of custom errors. This preserves label information -- vs rethrowing. catchJustParser :: Monad m => (e -> Maybe b) -> ParserT l s e m a -> (b -> ParserT l s e m a) -> ParserT l s e m a -- | Throws a custom error throwParser :: Monad m => e -> ParserT l s e m a -- | Catches a custom error catchParser :: Monad m => ParserT l s e m a -> (e -> ParserT l s e m a) -> ParserT l s e m a -- | The empty parser emptyParser :: Monad m => ParserT l s e m a -- | Yields from the first parser of the two that returns a successfull -- result. Otherwise will merge and yield all errors. orParser :: Monad m => ParserT l s e m a -> ParserT l s e m a -> ParserT l s e m a -- | Yields the LONGEST string of 0 or more successes of the given parser. -- Failures will be silenced. greedyStarParser :: (Chunked seq elem, Monad m) => ParserT l s e m elem -> ParserT l s e m seq -- | Same as greedyStarParser but discards the result. greedyStarParser_ :: Monad m => ParserT l s e m a -> ParserT l s e m () -- | Yields the LONGEST string of 1 or more successes of the given parser. -- Failures in the tail will be silenced, but those in the head will be -- returned. greedyPlusParser :: (Chunked seq elem, Monad m) => ParserT l s e m elem -> ParserT l s e m seq -- | Same as greedyPlusParser but discards the result. greedyPlusParser_ :: Monad m => ParserT l s e m a -> ParserT l s e m () -- | If the parser does not succeed, yield the given value. defaultParser :: Monad m => a -> ParserT l s e m a -> ParserT l s e m a -- | A parser that yields Nothing if the parser does not succeed, -- otherwise wraps success in Just. optionalParser :: Monad m => ParserT l s e m a -> ParserT l s e m (Maybe a) -- | Run the parser speculatively and return results. Does not advance -- state or throw errors. reflectParser :: Monad m => ParserT l s e m a -> ParserT l s e m (Maybe (ParseResult l s e a)) -- | Removes all failures from the parse results. Catches more errors than -- 'catchError (const empty)' because this includes stream errors, not -- just custom errors. If you want more fine-grained control, use -- reflectParser and map over the results. silenceParser :: Monad m => ParserT l s e m a -> ParserT l s e m a -- | Yield the results of the given parser, but rewind back to the starting -- state. Note that these results may contain errors, so you may want to -- stifle them with silenceParser, for example. lookAheadParser :: Monad m => ParserT l s e m a -> ParserT l s e m a -- | Push the label and current state onto the parse error mark stack. -- Useful to delimit named sub-spans for error reporting. markParser :: Monad m => Maybe l -> ParserT l s e m a -> ParserT l s e m a -- | Like markParser but allows you to mutate state. See -- withToken and withChunk. markWithStateParser :: Monad m => Maybe l -> (s -> (b, s)) -> (b -> ParserT l s e m a) -> ParserT l s e m a -- | Like markParser but allows you to mutate state. See -- withToken and withChunk. markWithOptStateParser :: Monad m => Maybe l -> (s -> Maybe (b, s)) -> (Maybe b -> ParserT l s e m a) -> ParserT l s e m a -- | Clear marks from parse errors. You can mark immediately after to widen -- the narrowest marked span to the range you want to report. unmarkParser :: Monad m => ParserT l s e m a -> ParserT l s e m a -- | If the first parser succeeds in the initial state, yield results from -- the second parser in the initial state. This is likely the look-ahead -- you want, since errors from the first parser are completely ignored. -- Use the first parser to check a prefix of input, and use the second to -- consume that input. commitParser :: Monad m => ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a -- | If the first parser yields NO results (success or failure), yield from -- the second. Note that this is different from orParser in that -- it does not try the second if there are errors in the first. You might -- use this on the outside of a complex parser with a fallback to -- fail to indicate that there are no matches. onEmptyParser :: Parser l s e a -> Parser l s e a -> Parser l s e a instance GHC.Base.Functor m => GHC.Base.Functor (SimpleParser.Parser.ParserT l s e m) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (SimpleParser.Parser.SeqPartition a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (SimpleParser.Parser.SeqPartition a b) instance GHC.Base.Monad m => GHC.Base.Applicative (SimpleParser.Parser.ParserT l s e m) instance GHC.Base.Monad m => GHC.Base.Monad (SimpleParser.Parser.ParserT l s e m) instance GHC.Base.Monad m => GHC.Base.Alternative (SimpleParser.Parser.ParserT l s e m) instance GHC.Base.Monad m => GHC.Base.MonadPlus (SimpleParser.Parser.ParserT l s e m) instance GHC.Base.Monad m => Control.Monad.State.Class.MonadState s (SimpleParser.Parser.ParserT l s e m) instance GHC.Base.Monad m => Control.Monad.Error.Class.MonadError e (SimpleParser.Parser.ParserT l s e m) instance GHC.Base.Monad m => Control.Monad.Fail.MonadFail (SimpleParser.Parser.ParserT l s e m) instance Control.Monad.Trans.Class.MonadTrans (SimpleParser.Parser.ParserT l s e) instance Control.Monad.Morph.MFunctor (SimpleParser.Parser.ParserT l s e) module SimpleParser.LookAhead data MatchCase l s e m a b MatchCase :: !Maybe l -> !a -> Bool -> !ParserT l s e m b -> MatchCase l s e m a b [matchCaseLabel] :: MatchCase l s e m a b -> !Maybe l [matchCaseChoose] :: MatchCase l s e m a b -> !a -> Bool [matchCaseHandle] :: MatchCase l s e m a b -> !ParserT l s e m b type PureMatchCase l s e a b = MatchCase l s e Identity a b data MatchBlock l s e m a b MatchBlock :: !ParserT l s e m a -> !ParserT l s e m b -> ![MatchCase l s e m a b] -> MatchBlock l s e m a b [matchBlockSelect] :: MatchBlock l s e m a b -> !ParserT l s e m a [matchBlockDefault] :: MatchBlock l s e m a b -> !ParserT l s e m b [matchBlockElems] :: MatchBlock l s e m a b -> ![MatchCase l s e m a b] type PureMatchBlock l s e a b = MatchBlock l s e Identity a b -- | Parse with look-ahead for each case and follow the first that matches -- (or follow the default if none do). lookAheadMatch :: Monad m => MatchBlock l s e m a b -> ParserT l s e m b -- | Same as lookAheadMatch but consumes the selector instead of -- looking ahead. Cases will not have to re-parse the selected portion. consumeMatch :: Monad m => MatchBlock l s e m a b -> ParserT l s e m b data MatchPos l MatchPos :: !Int -> !Maybe l -> MatchPos l [matchPosIndex] :: MatchPos l -> !Int [matchPosLabel] :: MatchPos l -> !Maybe l data LookAheadTestResult l LookAheadTestEmpty :: LookAheadTestResult l LookAheadTestDefault :: LookAheadTestResult l LookAheadTestMatches :: !NESeq (MatchPos l) -> LookAheadTestResult l -- | Test which branches match the look-ahead. Useful to assert that your -- parser makes exclusive choices. lookAheadTest :: Monad m => MatchBlock l s e m a b -> s -> m (LookAheadTestResult l) pureLookAheadTest :: PureMatchBlock l s e a b -> s -> LookAheadTestResult l -- | Simple look-ahead that selects a parser based on first equal prefix. lookAheadSimple :: (Monad m, Eq a) => ParserT l s e m a -> ParserT l s e m b -> [(a, ParserT l s e m b)] -> ParserT l s e m b instance GHC.Show.Show l => GHC.Show.Show (SimpleParser.LookAhead.MatchPos l) instance GHC.Classes.Eq l => GHC.Classes.Eq (SimpleParser.LookAhead.MatchPos l) instance GHC.Show.Show l => GHC.Show.Show (SimpleParser.LookAhead.LookAheadTestResult l) instance GHC.Classes.Eq l => GHC.Classes.Eq (SimpleParser.LookAhead.LookAheadTestResult l) -- | Useful combinators for ParserT and Stream. Classified as -- SAFE or UNSAFE. SAFE always return a value. UNSAFE throw. module SimpleParser.Input -- | Fetches the next token from the stream and runs the callback. withToken :: (Stream s, Monad m) => Maybe l -> (Maybe (Token s) -> ParserT l s e m a) -> ParserT l s e m a -- | Fetches the next chunk from the stream and runs the callback. withChunk :: (Stream s, Monad m) => Maybe l -> Int -> (Maybe (Chunk s) -> ParserT l s e m a) -> ParserT l s e m a -- | Return the next token, if any, but don't consume it. (SAFE) peekToken :: (Stream s, Monad m) => ParserT l s e m (Maybe (Token s)) -- | Return the next token, if any, and consume it. (SAFE) popToken :: (Stream s, Monad m) => ParserT l s e m (Maybe (Token s)) -- | Return the next chunk of the given size, if any, but don't consume it. -- May return a smaller chunk at end of stream, but never returns an -- empty chunk. (SAFE) peekChunk :: (Stream s, Monad m) => Int -> ParserT l s e m (Maybe (Chunk s)) -- | Return the next chunk of the given size, if any, and consume it. May -- return a smaller chunk at end of stream, but never returns an empty -- chunk. (SAFE) popChunk :: (Stream s, Monad m) => Int -> ParserT l s e m (Maybe (Chunk s)) -- | Drop the next chunk of the given size, if any, and consume it. May -- return a smaller size at end of stream, but never returns size 0. -- (SAFE) dropChunk :: (Stream s, Monad m) => Int -> ParserT l s e m (Maybe Int) -- | Is this the end of the stream? (SAFE) isEnd :: (Stream s, Monad m) => ParserT l s e m Bool -- | Match the end of the stream or terminate the parser. (UNSAFE) matchEnd :: (Stream s, Monad m) => ParserT l s e m () -- | Return the next token or terminate the parser at end of stream. -- (UNSAFE) anyToken :: (Stream s, Monad m) => ParserT l s e m (Token s) -- | Return the next chunk of the given size or terminate the parser at end -- of stream. May return a smaller chunk at end of stream, but never -- returns an empty chunk. (UNSAFE) anyChunk :: (Stream s, Monad m) => Int -> ParserT l s e m (Chunk s) -- | Match the next token with the given predicate or terminate the parser -- at predicate false or end of stream. (UNSAFE) satisfyToken :: (Stream s, Monad m) => Maybe l -> (Token s -> Bool) -> ParserT l s e m (Token s) -- | Folds over a stream of tokens while the boolean value is true. Always -- succeeds, even at end of stream. Only consumes greediest match. (SAFE) foldTokensWhile :: (Stream s, Monad m) => (Token s -> x -> (Bool, x)) -> x -> ParserT l s e m x -- | Take tokens into a chunk while they satisfy the given predicate. -- Always succeeds, even at end of stream. May return an empty chunk. -- Only yields greediest match. (SAFE) takeTokensWhile :: (Stream s, Monad m) => (Token s -> Bool) -> ParserT l s e m (Chunk s) -- | Take tokens into a chunk while they satisfy the given predicate. Only -- succeeds if 1 or more tokens are taken, so it never returns an empty -- chunk. Also takes an optional label to describe the predicate. -- (UNSAFE) takeTokensWhile1 :: (Stream s, Monad m) => Maybe l -> (Token s -> Bool) -> ParserT l s e m (Chunk s) -- | Drop tokens and return chunk size while they satisfy the given -- predicate. Always succeeds, even at end of stream. May return empty -- chunk size 0. Only drops greediest match. (SAFE) dropTokensWhile :: (Stream s, Monad m) => (Token s -> Bool) -> ParserT l s e m Int -- | Drop tokens and return chunk size while they satisfy the given -- predicate. Only succeeds if 1 or more tokens are dropped. Also takes -- an optional label to describe the predicate. (UNSAFE) dropTokensWhile1 :: (Stream s, Monad m) => Maybe l -> (Token s -> Bool) -> ParserT l s e m Int -- | Match token with equality or terminate the parser at inequality or end -- of stream. (UNSAFE) matchToken :: (Stream s, Monad m, Eq (Token s)) => Token s -> ParserT l s e m (Token s) -- | Match chunk with equality or terminate the parser at inequality or end -- of stream. (UNSAFE) matchChunk :: (Stream s, Monad m, Eq (Chunk s)) => Chunk s -> ParserT l s e m (Chunk s) -- | Common parsers. See Text.Megaparsec.Char.Lexer. module SimpleParser.Common -- | Enumeration of common labels in textual parsing. data TextLabel TextLabelSpace :: TextLabel TextLabelHSpace :: TextLabel TextLabelDigit :: TextLabel class EmbedTextLabel l embedTextLabel :: EmbedTextLabel l => TextLabel -> l -- | Union of text and custom labels data CompoundTextLabel l CompoundTextLabelText :: !TextLabel -> CompoundTextLabel l CompoundTextLabelCustom :: !l -> CompoundTextLabel l -- | Yields the maximal list of separated items. May return an empty list. sepByParser :: (Chunked seq elem, Monad m) => ParserT l s e m elem -> ParserT l s e m () -> ParserT l s e m seq -- | Parses between start and end markers. betweenParser :: Monad m => ParserT l s e m () -> ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a -- | A wrapper for lexemes (equivalent to Megaparsec's lexeme). lexemeParser :: Monad m => ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a -- | Consumes a newline character. newlineParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m () -- | Consumes 0 or more space characters. spaceParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m () -- | Consumes 0 or more non-line-break space characters hspaceParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m () -- | Consumes 1 or more space characters. spaceParser1 :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m () -- | Consumes 1 or more non-line-break space characters hspaceParser1 :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m () -- | Parses an integer in decimal representation (equivalent to -- Megaparsec's decimal). decimalParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m, Num a) => ParserT l s e m a -- | Predicate for satisfying the start of signed numbers signedNumStartPred :: Char -> Bool -- | Parses a floating point value as a Scientific number -- (equivalent to Megaparsec's scientific). scientificParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m Scientific -- | Parses a number as a literal integer or a Scientific number. -- Though Scientific can represent integers, this allows you to -- distinugish integer literals from scientific literals since that -- information is lost after parsing. numParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m (Either Integer Scientific) data Sign SignPos :: Sign SignNeg :: Sign -- | Consumes an optional + or - representing the sign of a number. signParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m (Maybe Sign) -- | Optionally negate the number according to the sign (treating -- Nothing as positive sign). applySign :: Num a => Maybe Sign -> a -> a -- | Parses an optional sign character followed by a number and yields a -- correctly-signed number (equivalend to Megaparsec's signed). signedParser :: (Stream s, Token s ~ Char, Monad m, Num a) => ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a -- | Given a quote charcter (like a single or double quote), yields the -- contents of the string bounded by those quotes. The contents may -- contain backslash-escaped quotes. Returns nothing if outside quotes -- are missing or the stream ends before unquote. escapedStringParser :: (Stream s, Token s ~ Char, Monad m) => Char -> ParserT l s e m (Chunk s) -- | Adds span information to parsed values. spanParser :: (PosStream s, Monad m) => (Span (Pos s) -> a -> b) -> ParserT l s e m a -> ParserT l s e m b -- | Gets the current stream position getStreamPos :: (PosStream s, Monad m) => ParserT l s e m (Pos s) instance GHC.Show.Show SimpleParser.Common.TextLabel instance GHC.Classes.Eq SimpleParser.Common.TextLabel instance Data.Traversable.Traversable SimpleParser.Common.CompoundTextLabel instance Data.Foldable.Foldable SimpleParser.Common.CompoundTextLabel instance GHC.Base.Functor SimpleParser.Common.CompoundTextLabel instance GHC.Show.Show l => GHC.Show.Show (SimpleParser.Common.CompoundTextLabel l) instance GHC.Classes.Eq l => GHC.Classes.Eq (SimpleParser.Common.CompoundTextLabel l) instance GHC.Show.Show SimpleParser.Common.Sign instance GHC.Classes.Eq SimpleParser.Common.Sign instance SimpleParser.Common.EmbedTextLabel (SimpleParser.Common.CompoundTextLabel l) instance SimpleParser.Common.EmbedTextLabel SimpleParser.Common.TextLabel module SimpleParser.Explain class ExplainLabel l explainLabel :: ExplainLabel l => l -> Builder explainLabelText :: ExplainLabel l => l -> Text data ErrorExplanation ErrorExplanation :: !Text -> !Maybe Text -> !Maybe Text -> ErrorExplanation [eeReason] :: ErrorExplanation -> !Text [eeExpected] :: ErrorExplanation -> !Maybe Text [eeActual] :: ErrorExplanation -> !Maybe Text class ExplainError e explainError :: ExplainError e => e -> ErrorExplanation type Explainable l s e = (TextualStream s, PosStream s, ExplainLabel l, ExplainError e) data ParseErrorExplanation p ParseErrorExplanation :: !Span p -> !Seq Text -> !Maybe Text -> !ErrorExplanation -> ParseErrorExplanation p [peeSpan] :: ParseErrorExplanation p -> !Span p [peeContext] :: ParseErrorExplanation p -> !Seq Text [peeDetails] :: ParseErrorExplanation p -> !Maybe Text [peeErrExp] :: ParseErrorExplanation p -> !ErrorExplanation explainParseError :: Explainable l s e => ParseError l s e -> ParseErrorExplanation (Pos s) buildParseErrorExplanation :: HasLinePos p => ParseErrorExplanation p -> Builder buildAllParseErrorExplanations :: (HasLinePos p, Foldable f) => f (ParseErrorExplanation p) -> Builder instance GHC.Show.Show SimpleParser.Explain.ErrorExplanation instance GHC.Classes.Eq SimpleParser.Explain.ErrorExplanation instance GHC.Show.Show p => GHC.Show.Show (SimpleParser.Explain.ParseErrorExplanation p) instance GHC.Classes.Eq p => GHC.Classes.Eq (SimpleParser.Explain.ParseErrorExplanation p) instance SimpleParser.Explain.ExplainError Data.Void.Void instance (SimpleParser.Stream.Token s GHC.Types.~ GHC.Types.Char, SimpleParser.Chunked.TextualChunked (SimpleParser.Stream.Chunk s)) => SimpleParser.Explain.ExplainError (SimpleParser.Result.StreamError s) instance (SimpleParser.Stream.Token s GHC.Types.~ GHC.Types.Char, SimpleParser.Chunked.TextualChunked (SimpleParser.Stream.Chunk s), SimpleParser.Explain.ExplainError e) => SimpleParser.Explain.ExplainError (SimpleParser.Result.CompoundError s e) instance SimpleParser.Explain.ExplainLabel Data.Void.Void instance SimpleParser.Explain.ExplainLabel SimpleParser.Common.TextLabel instance SimpleParser.Explain.ExplainLabel l => SimpleParser.Explain.ExplainLabel (SimpleParser.Common.CompoundTextLabel l) module SimpleParser.Errata type LinePosExplainable l s e = (Explainable l s e, HasLinePos (Pos s)) errataParseError :: LinePosExplainable l s e => Style -> PointerStyle -> FilePath -> ParseError l s e -> Block errataParseResult :: LinePosExplainable l s e => Style -> PointerStyle -> FilePath -> ParseResult l s e a -> [Block] module SimpleParser.Interactive data ErrorStyle ErrorStyleErrata :: ErrorStyle ErrorStyleExplain :: ErrorStyle parseInteractiveStyle :: (s ~ LinePosStream Text, Explainable l s e, Show a) => ErrorStyle -> Parser l s e a -> String -> IO () parseInteractive :: (s ~ LinePosStream Text, Explainable l s e, Show a) => Parser l s e a -> String -> IO () instance GHC.Show.Show SimpleParser.Interactive.ErrorStyle instance GHC.Classes.Eq SimpleParser.Interactive.ErrorStyle module SimpleParser.CharString newtype CharString CharString :: ByteString -> CharString [unCharString] :: CharString -> ByteString newtype LazyCharString LazyCharString :: ByteString -> LazyCharString [unLazyCharString] :: LazyCharString -> ByteString toLazyCharString :: CharString -> LazyCharString toStrictCharString :: LazyCharString -> CharString instance Data.String.IsString SimpleParser.CharString.CharString instance GHC.Base.Monoid SimpleParser.CharString.CharString instance GHC.Base.Semigroup SimpleParser.CharString.CharString instance GHC.Show.Show SimpleParser.CharString.CharString instance GHC.Classes.Ord SimpleParser.CharString.CharString instance GHC.Classes.Eq SimpleParser.CharString.CharString instance Data.String.IsString SimpleParser.CharString.LazyCharString instance GHC.Base.Monoid SimpleParser.CharString.LazyCharString instance GHC.Base.Semigroup SimpleParser.CharString.LazyCharString instance GHC.Show.Show SimpleParser.CharString.LazyCharString instance GHC.Classes.Ord SimpleParser.CharString.LazyCharString instance GHC.Classes.Eq SimpleParser.CharString.LazyCharString instance SimpleParser.Chunked.Chunked SimpleParser.CharString.LazyCharString GHC.Types.Char instance SimpleParser.Chunked.TextualChunked SimpleParser.CharString.LazyCharString instance SimpleParser.Stream.Stream SimpleParser.CharString.LazyCharString instance SimpleParser.Chunked.Chunked SimpleParser.CharString.CharString GHC.Types.Char instance SimpleParser.Chunked.TextualChunked SimpleParser.CharString.CharString instance SimpleParser.Stream.Stream SimpleParser.CharString.CharString module SimpleParser.Throw data EmptyParseError EmptyParseError :: EmptyParseError -- | Runs a parser and throws bundled errors / no parse result errors as -- exceptions. runParserThrow :: (Typeable l, Typeable s, Typeable e, Typeable (Token s), Typeable (Chunk s), Show l, Show s, Show e, Show (Token s), Show (Chunk s), MonadThrow m) => Parser l s e a -> s -> m (ParseSuccess s a) -- | The easiest way to fully consume input and throw errors. runParserEnd :: (Typeable l, Typeable s, Typeable e, Typeable (Token s), Typeable (Chunk s), Show l, Show s, Show e, Show (Token s), Show (Chunk s), Stream s, MonadThrow m) => Parser l s e a -> s -> m a instance GHC.Show.Show SimpleParser.Throw.EmptyParseError instance GHC.Classes.Eq SimpleParser.Throw.EmptyParseError instance GHC.Exception.Type.Exception SimpleParser.Throw.EmptyParseError -- | This is basically a simpler and slower (Mega)Parsec that is fully -- backtracking by default. -- -- The root module re-exports all modules. See -- SimpleParser.Examples.Json or the test suit for examples, -- SimpleParser.Parser for the core transformer, -- SimpleParser.Stream for the source abstraction, or -- SimpleParser.Input for useful combinators. module SimpleParser -- | Parses S-expressions module SimpleParser.Examples.Sexp newtype Sexp Sexp :: SexpF Sexp -> Sexp [unSexp] :: Sexp -> SexpF Sexp data SexpF a SexpAtom :: !Atom -> SexpF a SexpList :: !Seq a -> SexpF a data Atom AtomIdent :: !Text -> Atom AtomString :: !Text -> Atom AtomInt :: !Integer -> Atom AtomSci :: !Scientific -> Atom data SexpLabel SexpLabelIdentStart :: SexpLabel SexpLabelEmbedText :: !TextLabel -> SexpLabel SexpLabelCustom :: !Text -> SexpLabel type SexpParserC s = TextualStream s type SexpParserM s a = Parser SexpLabel s Void a sexpParser :: SexpParserC s => SexpParserM s Sexp instance GHC.Show.Show SimpleParser.Examples.Sexp.Atom instance GHC.Classes.Eq SimpleParser.Examples.Sexp.Atom instance Data.Traversable.Traversable SimpleParser.Examples.Sexp.SexpF instance Data.Foldable.Foldable SimpleParser.Examples.Sexp.SexpF instance GHC.Base.Functor SimpleParser.Examples.Sexp.SexpF instance GHC.Show.Show a => GHC.Show.Show (SimpleParser.Examples.Sexp.SexpF a) instance GHC.Classes.Eq a => GHC.Classes.Eq (SimpleParser.Examples.Sexp.SexpF a) instance GHC.Show.Show SimpleParser.Examples.Sexp.SexpLabel instance GHC.Classes.Eq SimpleParser.Examples.Sexp.SexpLabel instance GHC.Show.Show SimpleParser.Examples.Sexp.Sexp instance GHC.Classes.Eq SimpleParser.Examples.Sexp.Sexp instance SimpleParser.Explain.ExplainLabel SimpleParser.Examples.Sexp.SexpLabel instance SimpleParser.Common.EmbedTextLabel SimpleParser.Examples.Sexp.SexpLabel -- | Parses JSON documents module SimpleParser.Examples.Json newtype Json Json :: JsonF Json -> Json [unJson] :: Json -> JsonF Json data JsonF a JsonObject :: !Seq (Text, a) -> JsonF a JsonArray :: !Seq a -> JsonF a JsonString :: !Text -> JsonF a JsonBool :: !Bool -> JsonF a JsonNum :: !Scientific -> JsonF a JsonNull :: JsonF a type JsonParserC s = (TextualStream s, Eq (Chunk s)) type JsonParserM s a = Parser TextLabel s Void a jsonParser :: JsonParserC s => JsonParserM s Json instance Data.Traversable.Traversable SimpleParser.Examples.Json.JsonF instance Data.Foldable.Foldable SimpleParser.Examples.Json.JsonF instance GHC.Base.Functor SimpleParser.Examples.Json.JsonF instance GHC.Show.Show a => GHC.Show.Show (SimpleParser.Examples.Json.JsonF a) instance GHC.Classes.Eq a => GHC.Classes.Eq (SimpleParser.Examples.Json.JsonF a) instance GHC.Show.Show SimpleParser.Examples.Json.Json instance GHC.Classes.Eq SimpleParser.Examples.Json.Json -- | Parses Sexp-formatted ASTs module SimpleParser.Examples.Ast data AstLabel AstLabelEmbedText :: !TextLabel -> AstLabel AstLabelCtorList :: AstLabel AstLabelCtorHead :: AstLabel AstLabelCtorBody :: !Text -> AstLabel AstLabelCustom :: !Text -> AstLabel type AstParserC s = (TextualStream s, Chunk s ~ Text) type AstParserM s e a = Parser AstLabel s e a data CtorRes e a CtorResFail :: !String -> CtorRes e a CtorResErr :: !e -> CtorRes e a CtorResVal :: !a -> CtorRes e a data Ctor s e t [Ctor0] :: CtorRes e t -> Ctor s e t [Ctor1] :: (a -> CtorRes e t) -> AstParserM s e a -> Ctor s e t [Ctor2] :: (a -> b -> CtorRes e t) -> AstParserM s e a -> AstParserM s e b -> Ctor s e t [Ctor3] :: (a -> b -> c -> CtorRes e t) -> AstParserM s e a -> AstParserM s e b -> AstParserM s e c -> Ctor s e t [Ctor4] :: (a -> b -> c -> d -> CtorRes e t) -> AstParserM s e a -> AstParserM s e b -> AstParserM s e c -> AstParserM s e d -> Ctor s e t [Ctor5] :: (a -> b -> c -> d -> x -> CtorRes e t) -> AstParserM s e a -> AstParserM s e b -> AstParserM s e c -> AstParserM s e d -> AstParserM s e x -> Ctor s e t [CtorN] :: (Seq a -> CtorRes e t) -> AstParserM s e a -> Ctor s e t type CtorDefns s e t = Map Text (Ctor s e t) astParser :: AstParserC s => AstParserM s e t -> (AstParserM s e t -> CtorDefns s e t) -> AstParserM s e t lexAstParser :: AstParserC s => AstParserM s e a -> AstParserM s e a identAstParser :: AstParserC s => Maybe AstLabel -> AstParserM s e Text instance GHC.Show.Show SimpleParser.Examples.Ast.AstLabel instance GHC.Classes.Eq SimpleParser.Examples.Ast.AstLabel instance Data.Traversable.Traversable (SimpleParser.Examples.Ast.CtorRes e) instance Data.Foldable.Foldable (SimpleParser.Examples.Ast.CtorRes e) instance GHC.Base.Functor (SimpleParser.Examples.Ast.CtorRes e) instance (GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (SimpleParser.Examples.Ast.CtorRes e a) instance (GHC.Classes.Ord e, GHC.Classes.Ord a) => GHC.Classes.Ord (SimpleParser.Examples.Ast.CtorRes e a) instance (GHC.Classes.Eq e, GHC.Classes.Eq a) => GHC.Classes.Eq (SimpleParser.Examples.Ast.CtorRes e a) instance GHC.Base.Applicative (SimpleParser.Examples.Ast.CtorRes e) instance GHC.Base.Monad (SimpleParser.Examples.Ast.CtorRes e) instance Control.Monad.Fail.MonadFail (SimpleParser.Examples.Ast.CtorRes e) instance Control.Monad.Error.Class.MonadError e (SimpleParser.Examples.Ast.CtorRes e) instance SimpleParser.Explain.ExplainLabel SimpleParser.Examples.Ast.AstLabel instance SimpleParser.Common.EmbedTextLabel SimpleParser.Examples.Ast.AstLabel -- | Parses simple Sexp-formatted logical propositions module SimpleParser.Examples.Prop type PropParserC s = AstParserC s type PropParserM s a = AstParserM s Void a data SProp v SPropVar :: !v -> SProp v SPropBool :: !Bool -> SProp v SPropNot :: SProp v -> SProp v SPropAnd :: !Seq (SProp v) -> SProp v SPropOr :: !Seq (SProp v) -> SProp v SPropIf :: !Seq (SProp v) -> SProp v -> SProp v SPropIff :: SProp v -> SProp v -> SProp v guard2 :: MonadFail m => Seq a -> m (Seq a) guardLast :: MonadFail m => Seq a -> m (Seq a, a) mkPropCtors :: PropParserM s (SProp Text) -> CtorDefns s Void (SProp Text) mkPropAtom :: PropParserC s => PropParserM s (SProp Text) propParser :: PropParserC s => PropParserM s (SProp Text) instance Data.Traversable.Traversable SimpleParser.Examples.Prop.SProp instance Data.Foldable.Foldable SimpleParser.Examples.Prop.SProp instance GHC.Base.Functor SimpleParser.Examples.Prop.SProp instance GHC.Show.Show v => GHC.Show.Show (SimpleParser.Examples.Prop.SProp v) instance GHC.Classes.Eq v => GHC.Classes.Eq (SimpleParser.Examples.Prop.SProp v)