{-# LANGUAGE ConstraintKinds, CPP, FlexibleContexts, FlexibleInstances, GADTs, GeneralizedNewtypeDeriving, InstanceSigs,
RankNTypes, ScopedTypeVariables, StandaloneDeriving, TypeApplications, TypeFamilies, TypeOperators,
UndecidableInstances #-}
module Text.Grampa.Internal.LeftRecursive (Fixed(..), SeparatedParser(..),
autochain, asLeaf, liftPositive, liftPure, mapPrimitive,
parseSeparated, separated)
where
import Control.Applicative
import Control.Monad (Monad(..), MonadPlus(..), void)
#if MIN_VERSION_base(4,13,0)
import Control.Monad (MonadFail(fail))
#endif
import Control.Monad.Trans.State.Lazy (State, evalState)
import qualified Control.Monad.Trans.State.Lazy as State
import Data.Functor.Compose (Compose(..))
import Data.Kind (Type)
import Data.Maybe (isJust)
import Data.Semigroup (Semigroup(..))
import Data.Monoid (Monoid(mempty), All(..), Any(..))
import Data.Monoid.Null (MonoidNull(null))
import Data.Monoid.Factorial (FactorialMonoid)
import Data.Monoid.Textual (TextualMonoid)
import Data.Semigroup.Cancellative (LeftReductive)
import qualified Data.Monoid.Factorial as Factorial
import qualified Data.Monoid.Textual as Textual
import Data.String (fromString)
import Data.Type.Equality ((:~:)(Refl))
import Witherable (Filterable(mapMaybe))
import qualified Text.Parser.Char as Char
import Text.Parser.Char (CharParsing)
import Text.Parser.Combinators (Parsing(..))
import Text.Parser.LookAhead (LookAheadParsing(..))
import qualified Rank2
import Text.Grampa.Class (GrammarParsing(..), InputParsing(..), InputCharParsing(..), MultiParsing(..),
AmbiguousParsing(..), CommittedParsing(..), ConsumedInputParsing(..),
DeterministicParsing(..),
TailsParsing(parseTails, parseAllTails),
ParseResults, ParseFailure(..), FailureDescription(..), Pos)
import Text.Grampa.Internal (FallibleResults(..),
AmbiguousAlternative(ambiguousOr), AmbiguityDecidable(..), AmbiguityWitness(..),
ParserFlags (ParserFlags, nullable, dependsOn),
Dependencies (DynamicDependencies, StaticDependencies),
TraceableParsing(..))
import Text.Grampa.Internal.Storable (Storable1(reuse1), Storable11(reuse11, store11))
import Prelude hiding (cycle, null, span, take, takeWhile)
type ResultAppend p (g :: (Type -> Type) -> Type) s =
GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s)
data Fixed p g s a =
Parser {
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1, forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect :: p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices :: ChoiceTree (Fixed p g s a),
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous :: Maybe (AmbiguityWitness a),
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g}
| DirectParser {
complete, direct0, direct1 :: p g s a}
| PositiveDirectParser {
complete :: p g s a}
data ChoiceTree a =
Leaf a
| SymmetricChoice (ChoiceTree a) (ChoiceTree a)
| LeftBiasedChoice (ChoiceTree a) (ChoiceTree a)
deriving Int -> ChoiceTree a -> ShowS
[ChoiceTree a] -> ShowS
ChoiceTree a -> String
(Int -> ChoiceTree a -> ShowS)
-> (ChoiceTree a -> String)
-> ([ChoiceTree a] -> ShowS)
-> Show (ChoiceTree a)
forall a. Show a => Int -> ChoiceTree a -> ShowS
forall a. Show a => [ChoiceTree a] -> ShowS
forall a. Show a => ChoiceTree a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> ChoiceTree a -> ShowS
showsPrec :: Int -> ChoiceTree a -> ShowS
$cshow :: forall a. Show a => ChoiceTree a -> String
show :: ChoiceTree a -> String
$cshowList :: forall a. Show a => [ChoiceTree a] -> ShowS
showList :: [ChoiceTree a] -> ShowS
Show
instance Functor ChoiceTree where
fmap :: forall a b. (a -> b) -> ChoiceTree a -> ChoiceTree b
fmap a -> b
f (Leaf a
a) = b -> ChoiceTree b
forall a. a -> ChoiceTree a
Leaf (a -> b
f a
a)
fmap a -> b
f (SymmetricChoice ChoiceTree a
a ChoiceTree a
b) = ChoiceTree b -> ChoiceTree b -> ChoiceTree b
forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
SymmetricChoice ((a -> b) -> ChoiceTree a -> ChoiceTree b
forall a b. (a -> b) -> ChoiceTree a -> ChoiceTree b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
a) ((a -> b) -> ChoiceTree a -> ChoiceTree b
forall a b. (a -> b) -> ChoiceTree a -> ChoiceTree b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
b)
fmap a -> b
f (LeftBiasedChoice ChoiceTree a
a ChoiceTree a
b) = ChoiceTree b -> ChoiceTree b -> ChoiceTree b
forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
LeftBiasedChoice ((a -> b) -> ChoiceTree a -> ChoiceTree b
forall a b. (a -> b) -> ChoiceTree a -> ChoiceTree b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
a) ((a -> b) -> ChoiceTree a -> ChoiceTree b
forall a b. (a -> b) -> ChoiceTree a -> ChoiceTree b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ChoiceTree a
b)
instance Foldable ChoiceTree where
foldMap :: forall m a. Monoid m => (a -> m) -> ChoiceTree a -> m
foldMap a -> m
f (Leaf a
a) = a -> m
f a
a
foldMap a -> m
f (SymmetricChoice ChoiceTree a
a ChoiceTree a
b) = (a -> m) -> ChoiceTree a -> m
forall m a. Monoid m => (a -> m) -> ChoiceTree a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> (a -> m) -> ChoiceTree a -> m
forall m a. Monoid m => (a -> m) -> ChoiceTree a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
b
foldMap a -> m
f (LeftBiasedChoice ChoiceTree a
a ChoiceTree a
b) = (a -> m) -> ChoiceTree a -> m
forall m a. Monoid m => (a -> m) -> ChoiceTree a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> (a -> m) -> ChoiceTree a -> m
forall m a. Monoid m => (a -> m) -> ChoiceTree a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f ChoiceTree a
b
collapseChoices :: (Alternative p, DeterministicParsing p) => ChoiceTree (p a) -> p a
collapseChoices :: forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices (SymmetricChoice ChoiceTree (p a)
p ChoiceTree (p a)
q) = ChoiceTree (p a) -> p a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
p p a -> p a -> p a
forall a. p a -> p a -> p a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ChoiceTree (p a) -> p a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
q
collapseChoices (LeftBiasedChoice ChoiceTree (p a)
p ChoiceTree (p a)
q) = ChoiceTree (p a) -> p a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
p p a -> p a -> p a
forall a. p a -> p a -> p a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> ChoiceTree (p a) -> p a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (p a)
q
collapseChoices (Leaf p a
p) = p a
p
data SeparatedParser p (g :: (Type -> Type) -> Type) s a =
FrontParser (p g s a)
| CycleParser {
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
cycleParser :: p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
backParser :: p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> ResultAppend p g s a
appendResultsArrow :: ResultAppend p g s a,
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> Dependencies g
dependencies :: Dependencies g}
| BackParser {
backParser :: p g s a}
newtype Union (g :: (Type -> Type) -> Type) = Union{forall (g :: (* -> *) -> *). Union g -> g (Const Bool)
getUnion :: g (Const Bool)}
instance (Rank2.Apply g, Rank2.Distributive g) => Semigroup (Union g) where
Union g (Const Bool)
g1 <> :: Union g -> Union g -> Union g
<> Union g (Const Bool)
g2 = g (Const Bool) -> Union g
forall (g :: (* -> *) -> *). g (Const Bool) -> Union g
Union ((forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
union g (Const Bool)
g1 g (Const Bool)
g2)
instance (Rank2.Apply g, Rank2.Distributive g) => Monoid (Union g) where
mempty :: Union g
mempty = g (Const Bool) -> Union g
forall (g :: (* -> *) -> *). g (Const Bool) -> Union g
Union ((forall a. Const Bool (Any a) -> Const Bool a)
-> Const Bool (g Any) -> g (Const Bool)
forall {k1} (g :: (k1 -> *) -> *) (m :: * -> *) (p :: k1 -> *)
(q :: k1 -> *).
(Distributive g, Functor m) =>
(forall (a :: k1). m (p a) -> q a) -> m (g p) -> g q
forall (m :: * -> *) (p :: * -> *) (q :: * -> *).
Functor m =>
(forall a. m (p a) -> q a) -> m (g p) -> g q
Rank2.cotraverse (Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Const Bool a)
-> (Const Bool (Any a) -> Bool)
-> Const Bool (Any a)
-> Const Bool a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool (Any a) -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (Bool -> Const Bool (g Any)
forall {k} a (b :: k). a -> Const a b
Const Bool
False))
mappend :: Union g -> Union g -> Union g
mappend = Union g -> Union g -> Union g
forall a. Semigroup a => a -> a -> a
(<>)
asLeaf :: Fixed p g s a -> Fixed p g s a
asLeaf :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p'
where p' :: Fixed p g s a
p' = Fixed p g s a
p{choices= Leaf p'}
asLeaf Fixed p g s a
p = Fixed p g s a
p
mapPrimitive :: forall p g s a b. AmbiguityDecidable b => (p g s a -> p g s b) -> Fixed p g s a -> Fixed p g s b
mapPrimitive :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a b.
AmbiguityDecidable b =>
(p g s a -> p g s b) -> Fixed p g s a -> Fixed p g s b
mapPrimitive p g s a -> p g s b
f p :: Fixed p g s a
p@PositiveDirectParser{} = PositiveDirectParser{complete :: p g s b
complete= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
mapPrimitive p g s a -> p g s b
f p :: Fixed p g s a
p@DirectParser{} = DirectParser{complete :: p g s b
complete= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s b
direct0= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
mapPrimitive p g s a -> p g s b
f p :: Fixed p g s a
p@Parser{} = Fixed p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s b)
choices= ChoiceTree (Fixed p g s b)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= forall a. AmbiguityDecidable a => Maybe (AmbiguityWitness a)
ambiguityWitness @b,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p,
indirect :: p g s b
indirect= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
direct :: p g s b
direct= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s b
direct0= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= p g s a -> p g s b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
general, general' :: (Rank2.Apply g, Alternative (p g s)) => Fixed p g s a -> Fixed p g s a
general :: forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
p = Parser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct :: p g s a
direct = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p',
direct0 :: p g s a
direct0= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p',
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p',
indirect :: p g s a
indirect= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p',
choices :: ChoiceTree (Fixed p g s a)
choices= Fixed p g s a -> ChoiceTree (Fixed p g s a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p',
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= case Fixed p g s a
p
of Parser{isAmbiguous :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
a} -> Maybe (AmbiguityWitness a)
a
Fixed p g s a
_ -> Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p'}
where p' :: Fixed p g s a
p' = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s a
p
general' :: forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' p :: Fixed p g s a
p@PositiveDirectParser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct :: p g s a
direct = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct0 :: p g s a
direct0= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
indirect :: p g s a
indirect= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
choices :: ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
cd-> Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
False (g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> Dependencies g)
-> g (Const Bool) -> Dependencies g
forall a b. (a -> b) -> a -> b
$ Const Bool a -> Const (ParserFlags g) a -> Const Bool a
forall a b. a -> b -> a
const (Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
False) (forall {a}. Const (ParserFlags g) a -> Const Bool a)
-> g (Const (ParserFlags g)) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const (ParserFlags g))
cd)}
general' p :: Fixed p g s a
p@DirectParser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct :: p g s a
direct = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p,
direct0 :: p g s a
direct0= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p,
indirect :: p g s a
indirect= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
choices :: ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
cd-> Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True (g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> Dependencies g)
-> g (Const Bool) -> Dependencies g
forall a b. (a -> b) -> a -> b
$ Const Bool a -> Const (ParserFlags g) a -> Const Bool a
forall a b. a -> b -> a
const (Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
False) (forall {a}. Const (ParserFlags g) a -> Const Bool a)
-> g (Const (ParserFlags g)) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const (ParserFlags g))
cd)}
general' p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p
type LeftRecParsing p g s f = (Eq s, LeftReductive s, FactorialMonoid s, Alternative (p g s),
TailsParsing (p g s), GrammarConstraint (p g s) g, ParserGrammar (p g s) ~ g,
Functor (ResultFunctor (p g s)), s ~ ParserInput (p g s), FallibleResults f,
Storable1 (GrammarFunctor (p g s)) (ParserFlags g),
Storable1 (GrammarFunctor (p g s)) Bool,
AmbiguousAlternative (GrammarFunctor (p g s)))
instance (Rank2.Apply g, GrammarFunctor (p g s) ~ f s, LeftRecParsing p g s f) => MultiParsing (Fixed p g s) where
type GrammarConstraint (Fixed p g s) g' = (GrammarConstraint (p g s) g', g ~ g',
Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g)
type ResultFunctor (Fixed p g s) = ResultFunctor (p g s)
parsePrefix :: forall s (g :: (* -> *) -> *).
(ParserInput (Fixed p g s) ~ s, GrammarConstraint (Fixed p g s) g,
Eq s, FactorialMonoid s) =>
g (Fixed p g s)
-> s -> g (Compose (ResultFunctor (Fixed p g s)) ((,) s))
parsePrefix g (Fixed p g s)
g s
input
| Just g (p g s)
directs <- (forall a. SeparatedParser p g s a -> Maybe (p g s a))
-> g (SeparatedParser p g s) -> Maybe (g (p g s))
forall {k} (g :: (k -> *) -> *) (m :: * -> *) (p :: k -> *)
(q :: k -> *).
(Traversable g, Applicative m) =>
(forall (a :: k). p a -> m (q a)) -> g p -> m (g q)
forall (m :: * -> *) (p :: * -> *) (q :: * -> *).
Applicative m =>
(forall a. p a -> m (q a)) -> g p -> m (g q)
Rank2.traverse SeparatedParser p g s a -> Maybe (p g s a)
SeparatedParser p g s a -> Maybe (p g s a)
forall a. SeparatedParser p g s a -> Maybe (p g s a)
forall {p :: ((* -> *) -> *) -> * -> * -> *} {g :: (* -> *) -> *}
{s} {a}.
SeparatedParser p g s a -> Maybe (p g s a)
getDirect g (SeparatedParser p g s)
g' = g (p g s) -> s -> g (Compose (ResultFunctor (p g s)) ((,) s))
forall s (g :: (* -> *) -> *).
(ParserInput (p g s) ~ s, GrammarConstraint (p g s) g, Eq s,
FactorialMonoid s) =>
g (p g s) -> s -> g (Compose (ResultFunctor (p g s)) ((,) s))
forall (m :: * -> *) s (g :: (* -> *) -> *).
(MultiParsing m, ParserInput m ~ s, GrammarConstraint m g, Eq s,
FactorialMonoid s) =>
g m -> s -> g (Compose (ResultFunctor m) ((,) s))
parsePrefix g (p g s)
directs s
input
| Bool
otherwise = (forall a. f s a -> Compose (ResultFunctor (p g s)) ((,) s) a)
-> g (f s) -> g (Compose (ResultFunctor (p g s)) ((,) s))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (ResultFunctor (p g s) (s, a)
-> Compose (ResultFunctor (p g s)) ((,) s) a
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (ResultFunctor (p g s) (s, a)
-> Compose (ResultFunctor (p g s)) ((,) s) a)
-> (f s a -> ResultFunctor (p g s) (s, a))
-> f s a
-> Compose (ResultFunctor (p g s)) ((,) s) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
GrammarParsing m =>
ParserInput m
-> GrammarFunctor m a -> ResultFunctor m (ParserInput m, a)
parsingResult @(p g s) s
ParserInput (p g s)
input) ((s, g (f s)) -> g (f s)
forall a b. (a, b) -> b
snd ((s, g (f s)) -> g (f s)) -> (s, g (f s)) -> g (f s)
forall a b. (a -> b) -> a -> b
$ [(s, g (f s))] -> (s, g (f s))
forall a. HasCallStack => [a] -> a
head ([(s, g (f s))] -> (s, g (f s))) -> [(s, g (f s))] -> (s, g (f s))
forall a b. (a -> b) -> a -> b
$ g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
(rl :: * -> * -> *) s.
(Apply g, Foldable g, Eq s, FactorialMonoid s, LeftReductive s,
TailsParsing (p g s), GrammarConstraint (p g s) g,
GrammarFunctor (p g s) ~ rl s, FallibleResults rl,
s ~ ParserInput (p g s)) =>
g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
parseSeparated g (SeparatedParser p g s)
g' s
s
input)
where g' :: g (SeparatedParser p g s)
g' = g (Fixed p g s) -> g (SeparatedParser p g s)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g,
AmbiguousAlternative (GrammarFunctor (p g s))) =>
g (Fixed p g s) -> g (SeparatedParser p g s)
separated g (Fixed p g s)
g (Fixed p g s)
g
getDirect :: SeparatedParser p g s a -> Maybe (p g s a)
getDirect (FrontParser p g s a
p) = p g s a -> Maybe (p g s a)
forall a. a -> Maybe a
Just p g s a
p
getDirect (BackParser p g s a
p) = p g s a -> Maybe (p g s a)
forall a. a -> Maybe a
Just p g s a
p
getDirect CycleParser{} = Maybe (p g s a)
forall a. Maybe a
Nothing
{-# INLINE parsePrefix #-}
parseComplete :: forall s (g :: (* -> *) -> *).
(ParserInput (Fixed p g s) ~ s, GrammarConstraint (Fixed p g s) g,
Eq s, FactorialMonoid s) =>
g (Fixed p g s) -> s -> g (ResultFunctor (Fixed p g s))
parseComplete g (Fixed p g s)
g s
input
| Just g (p g s)
directs <- (forall a. SeparatedParser p g s a -> Maybe (p g s a))
-> g (SeparatedParser p g s) -> Maybe (g (p g s))
forall {k} (g :: (k -> *) -> *) (m :: * -> *) (p :: k -> *)
(q :: k -> *).
(Traversable g, Applicative m) =>
(forall (a :: k). p a -> m (q a)) -> g p -> m (g q)
forall (m :: * -> *) (p :: * -> *) (q :: * -> *).
Applicative m =>
(forall a. p a -> m (q a)) -> g p -> m (g q)
Rank2.traverse SeparatedParser p g s a -> Maybe (p g s a)
SeparatedParser p g s a -> Maybe (p g s a)
forall a. SeparatedParser p g s a -> Maybe (p g s a)
forall {p :: ((* -> *) -> *) -> * -> * -> *} {g :: (* -> *) -> *}
{s} {a}.
SeparatedParser p g s a -> Maybe (p g s a)
getDirect g (SeparatedParser p g s)
g' = g (p g s) -> s -> g (ResultFunctor (p g s))
forall s (g :: (* -> *) -> *).
(ParserInput (p g s) ~ s, GrammarConstraint (p g s) g, Eq s,
FactorialMonoid s) =>
g (p g s) -> s -> g (ResultFunctor (p g s))
forall (m :: * -> *) s (g :: (* -> *) -> *).
(MultiParsing m, ParserInput m ~ s, GrammarConstraint m g, Eq s,
FactorialMonoid s) =>
g m -> s -> g (ResultFunctor m)
parseComplete g (p g s)
directs s
input
| Bool
otherwise = (forall a. f s a -> ResultFunctor (Fixed p g s) a)
-> g (f s) -> g (ResultFunctor (Fixed p g s))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (((s, a) -> a
forall a b. (a, b) -> b
snd ((s, a) -> a)
-> ResultFunctor (p g s) (s, a) -> ResultFunctor (p g s) a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (ResultFunctor (p g s) (s, a) -> ResultFunctor (p g s) a)
-> (f s a -> ResultFunctor (p g s) (s, a))
-> f s a
-> ResultFunctor (p g s) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
GrammarParsing m =>
ParserInput m
-> GrammarFunctor m a -> ResultFunctor m (ParserInput m, a)
parsingResult @(p g s) s
ParserInput (p g s)
input)
(g (f s) -> g (ResultFunctor (Fixed p g s)))
-> g (f s) -> g (ResultFunctor (Fixed p g s))
forall a b. (a -> b) -> a -> b
$ (s, g (f s)) -> g (f s)
forall a b. (a, b) -> b
snd ((s, g (f s)) -> g (f s)) -> (s, g (f s)) -> g (f s)
forall a b. (a -> b) -> a -> b
$ [(s, g (f s))] -> (s, g (f s))
forall a. HasCallStack => [a] -> a
head ([(s, g (f s))] -> (s, g (f s))) -> [(s, g (f s))] -> (s, g (f s))
forall a b. (a -> b) -> a -> b
$ g (p g s)
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
forall (m :: * -> *) (g :: (* -> *) -> *).
(TailsParsing m, GrammarConstraint m g, Functor g) =>
g m
-> [(ParserInput m, g (GrammarFunctor m))]
-> [(ParserInput m, g (GrammarFunctor m))]
forall (g :: (* -> *) -> *).
(GrammarConstraint (p g s) g, Functor g) =>
g (p g s)
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
parseAllTails g (p g s)
g (p g s)
close ([(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))])
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
forall a b. (a -> b) -> a -> b
$ g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
(rl :: * -> * -> *) s.
(Apply g, Foldable g, Eq s, FactorialMonoid s, LeftReductive s,
TailsParsing (p g s), GrammarConstraint (p g s) g,
GrammarFunctor (p g s) ~ rl s, FallibleResults rl,
s ~ ParserInput (p g s)) =>
g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
parseSeparated g (SeparatedParser p g s)
g' s
s
input
where g' :: g (SeparatedParser p g s)
g' = g (Fixed p g s) -> g (SeparatedParser p g s)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g,
AmbiguousAlternative (GrammarFunctor (p g s))) =>
g (Fixed p g s) -> g (SeparatedParser p g s)
separated g (Fixed p g s)
g (Fixed p g s)
g
getDirect :: SeparatedParser p g s a -> Maybe (p g s a)
getDirect (FrontParser p g s a
p) = p g s a -> Maybe (p g s a)
forall a. a -> Maybe a
Just p g s a
p
getDirect (BackParser p g s a
p) = p g s a -> Maybe (p g s a)
forall a. a -> Maybe a
Just p g s a
p
getDirect CycleParser{} = Maybe (p g s a)
forall a. Maybe a
Nothing
close :: g (p g s)
close :: g (p g s)
close = (forall a. p g s a -> p g s a) -> g (p g s) -> g (p g s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (p g s a -> p g s () -> p g s a
forall a b. p g s a -> p g s b -> p g s a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* p g s ()
forall (m :: * -> *). Parsing m => m ()
eof) g (p g s)
forall (m :: * -> *) (g :: (* -> *) -> *).
(GrammarParsing m, g ~ ParserGrammar m, GrammarConstraint m g,
Distributive g) =>
g m
forall (g :: (* -> *) -> *).
(g ~ ParserGrammar (p g s), GrammarConstraint (p g s) g,
Distributive g) =>
g (p g s)
selfReferring
{-# INLINE parseComplete #-}
instance (Rank2.Apply g, GrammarFunctor (p g s) ~ f s, LeftRecParsing p g s f) => GrammarParsing (Fixed p g s) where
type ParserGrammar (Fixed p g s) = g
type GrammarFunctor (Fixed p g s) = GrammarFunctor (p g s)
parsingResult :: s -> GrammarFunctor (p g s) a -> ResultFunctor (p g s) (s, a)
parsingResult :: forall a.
s -> GrammarFunctor (p g s) a -> ResultFunctor (p g s) (s, a)
parsingResult s
s = forall (m :: * -> *) a.
GrammarParsing m =>
ParserInput m
-> GrammarFunctor m a -> ResultFunctor m (ParserInput m, a)
parsingResult @(p g s) s
ParserInput (p g s)
s
nonTerminal :: (Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g) =>
(g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a) -> Fixed p g s a
nonTerminal :: forall a.
(Apply g, Distributive g, Traversable g) =>
(g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a)
-> Fixed p g s a
nonTerminal g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a
f = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= p g s a
ind,
direct :: p g s a
direct= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
direct0 :: p g s a
direct0= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
direct1 :: p g s a
direct1= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
indirect :: p g s a
indirect= p g s a
ind,
choices :: ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= f s a -> ParserFlags g
forall b. f s b -> ParserFlags g
forall (s :: * -> *) a b. Storable1 s a => s b -> a
reuse1 (f s a -> ParserFlags g)
-> (g (Const (ParserFlags g)) -> f s a)
-> g (Const (ParserFlags g))
-> ParserFlags g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (f s) -> f s a
g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a
f (g (f s) -> f s a)
-> (g (Const (ParserFlags g)) -> g (f s))
-> g (Const (ParserFlags g))
-> f s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Const (ParserFlags g) a -> f s a)
-> g (Const (ParserFlags g)) -> g (f s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap Const (ParserFlags g) a -> f s a
forall a. Const (ParserFlags g) a -> f s a
forall a b. Const (ParserFlags g) a -> f s b
forall (s :: * -> *) (t :: * -> *) a b.
Storable11 s t =>
t a -> s b
store11 (g (Const (ParserFlags g)) -> g (f s))
-> (g (Const (ParserFlags g)) -> g (Const (ParserFlags g)))
-> g (Const (ParserFlags g))
-> g (f s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
addSelf}
where ind :: p g s a
ind = (g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a) -> p g s a
forall (m :: * -> *) (g :: (* -> *) -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, GrammarConstraint m g) =>
(g (GrammarFunctor m) -> GrammarFunctor m a) -> m a
forall (g :: (* -> *) -> *) a.
(g ~ ParserGrammar (p g s), GrammarConstraint (p g s) g) =>
(g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a) -> p g s a
nonTerminal g (GrammarFunctor (p g s)) -> GrammarFunctor (p g s) a
f
addSelf :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
addSelf g (Const (ParserFlags g))
g = (forall a.
Const (g (Const Bool)) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a)
-> g (Const (g (Const Bool)))
-> g (Const (ParserFlags g))
-> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (g (Const Bool)) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a
forall a.
Const (g (Const Bool)) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a
adjust g (Const (g (Const Bool)))
forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits g (Const (ParserFlags g))
g
adjust :: forall b. Const (g (Const Bool)) b -> Const (ParserFlags g) b -> Const (ParserFlags g) b
adjust :: forall a.
Const (g (Const Bool)) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a
adjust (Const g (Const Bool)
bit) (Const (ParserFlags Bool
n (StaticDependencies g (Const Bool)
d))) =
ParserFlags g -> Const (ParserFlags g) b
forall {k} a (b :: k). a -> Const a b
Const ParserFlags{
nullable :: Bool
nullable= Bool
n,
dependsOn :: Dependencies g
dependsOn= g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies ((forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
union g (Const Bool)
bit g (Const Bool)
d)}
adjust Const (g (Const Bool)) b
_ flags :: Const (ParserFlags g) b
flags@(Const (ParserFlags Bool
_ Dependencies g
DynamicDependencies)) = Const (ParserFlags g) b
flags
{-# INLINE nonTerminal #-}
recursive :: forall a. Fixed p g s a -> Fixed p g s a
recursive = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general
chainRecursive :: forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (Fixed p g s), f ~ GrammarFunctor (Fixed p g s),
GrammarConstraint (Fixed p g s) g) =>
(f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chainRecursive = ((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
(f :: * -> *) (rl :: * -> * -> *) a.
(Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s,
LeftRecParsing p g s rl) =>
((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
chainWith (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (p g s), f ~ GrammarFunctor (p g s),
GrammarConstraint (p g s) g) =>
(f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
chainRecursive
{-# INLINABLE chainRecursive #-}
chainLongestRecursive :: forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (Fixed p g s), f ~ GrammarFunctor (Fixed p g s),
GrammarConstraint (Fixed p g s) g) =>
(f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chainLongestRecursive = ((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
(f :: * -> *) (rl :: * -> * -> *) a.
(Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s,
LeftRecParsing p g s rl) =>
((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
chainWith (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (p g s), f ~ GrammarFunctor (p g s),
GrammarConstraint (p g s) g) =>
(f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
chainLongestRecursive
{-# INLINABLE chainLongestRecursive #-}
chainWith :: (Rank2.Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s, LeftRecParsing p g s rl)
=> ((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> ((f a -> g f -> g f) -> Fixed p g s a -> Fixed p g s a -> Fixed p g s a)
chainWith :: forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
(f :: * -> *) (rl :: * -> * -> *) a.
(Apply g, GrammarFunctor (p g s) ~ f, f ~ rl s,
LeftRecParsing p g s rl) =>
((f a -> g f -> g f) -> p g s a -> p g s a -> p g s a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> Fixed p g s a
-> Fixed p g s a
chainWith (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign = Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chain
where chain :: Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chain Fixed p g s a
base recurse :: Fixed p g s a
recurse@Parser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
base) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
direct :: p g s a
direct= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
base) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
direct0 :: p g s a
direct0= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
base) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
direct1 :: p g s a
direct1= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
base) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
indirect :: p g s a
indirect= (f a -> g f -> g f) -> p g s a -> p g s a -> p g s a
f f a -> g f -> g f
assign (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
base) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
recurse),
choices :: ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Fixed p g s a -> Maybe (AmbiguityWitness a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
base Maybe (AmbiguityWitness a)
-> Maybe (AmbiguityWitness a) -> Maybe (AmbiguityWitness a)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> Maybe (AmbiguityWitness a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
recurse,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let ParserFlags Bool
pn Dependencies g
pd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
base g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
recurse g (Const (ParserFlags g))
deps
qd' :: Dependencies g
qd' = case Dependencies g
qd
of Dependencies g
DynamicDependencies -> Dependencies g
forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
StaticDependencies g (Const Bool)
g -> g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> g (Const Bool)
clearOwnDep g (Const Bool)
g)
in Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags (Bool
pn Bool -> Bool -> Bool
&& Bool
qn) (Dependencies g -> Dependencies g -> Dependencies g
forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd')}
chain Fixed p g s a
base Fixed p g s a
recurse = Fixed p g s a
recurse Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a
base
clearOwnDep :: g (Const Bool) -> g (Const Bool)
clearOwnDep = (forall a. f a -> Const Bool a) -> g f -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap f a -> Const Bool a
rl s a -> Const Bool a
forall a. f a -> Const Bool a
forall b a. rl s b -> Const Bool a
forall (s :: * -> *) (t :: * -> *) b a.
Storable11 s t =>
s b -> t a
reuse11 (g f -> g (Const Bool))
-> (g (Const Bool) -> g f) -> g (Const Bool) -> g (Const Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> g f -> g f
assign (Const Bool Any -> f a
forall a b. Const Bool a -> f b
forall (s :: * -> *) (t :: * -> *) a b.
Storable11 s t =>
t a -> s b
store11 (Const Bool Any -> f a) -> Const Bool Any -> f a
forall a b. (a -> b) -> a -> b
$ Bool -> Const Bool Any
forall {k} a (b :: k). a -> Const a b
Const Bool
False) (g f -> g f) -> (g (Const Bool) -> g f) -> g (Const Bool) -> g f
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Const Bool a -> f a) -> g (Const Bool) -> g f
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap Const Bool a -> f a
forall a. Const Bool a -> f a
forall a b. Const Bool a -> f b
forall (s :: * -> *) (t :: * -> *) a b.
Storable11 s t =>
t a -> s b
store11
{-# INLINE chainWith #-}
bits :: forall (g :: (Type -> Type) -> Type). (Rank2.Distributive g, Rank2.Traversable g) => g (Const (g (Const Bool)))
bits :: forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits = g (Const Int)
start g (Const Int)
-> g (Const (g (Const Bool))) -> g (Const (g (Const Bool)))
forall a b. a -> b -> b
`seq` (forall a. Const Int a -> Const (g (Const Bool)) a)
-> g (Const Int) -> g (Const (g (Const Bool)))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap Const Int a -> Const (g (Const Bool)) a
forall a. Const Int a -> Const (g (Const Bool)) a
oneBit g (Const Int)
start
where start :: g (Const Int)
start = State Int (g (Const Int)) -> Int -> g (Const Int)
forall s a. State s a -> s -> a
evalState ((forall a. Maybe a -> StateT Int Identity (Const Int a))
-> g Maybe -> State Int (g (Const Int))
forall {k} (g :: (k -> *) -> *) (m :: * -> *) (p :: k -> *)
(q :: k -> *).
(Traversable g, Applicative m) =>
(forall (a :: k). p a -> m (q a)) -> g p -> m (g q)
forall (m :: * -> *) (p :: * -> *) (q :: * -> *).
Applicative m =>
(forall a. p a -> m (q a)) -> g p -> m (g q)
Rank2.traverse Maybe a -> State Int (Const Int a)
forall a. Maybe a -> StateT Int Identity (Const Int a)
forall (f :: * -> *) a. f a -> State Int (Const Int a)
next (Maybe (g Maybe) -> g Maybe
forall (g :: (* -> *) -> *) (f :: * -> *).
(Distributive g, Monad f) =>
f (g f) -> g f
Rank2.distributeJoin Maybe (g Maybe)
forall a. Maybe a
Nothing)) Int
0
oneBit :: Const Int a -> Const (g (Const Bool)) a
next :: f a -> State Int (Const Int a)
oneBit :: forall a. Const Int a -> Const (g (Const Bool)) a
oneBit (Const Int
i) = g (Const Bool) -> Const (g (Const Bool)) a
forall {k} a (b :: k). a -> Const a b
Const ((forall a. Const Int a -> Const Bool a)
-> g (Const Int) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Const Bool a)
-> (Const Int a -> Bool) -> Const Int a -> Const Bool a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
==) (Int -> Bool) -> (Const Int a -> Int) -> Const Int a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Int a -> Int
forall {k} a (b :: k). Const a b -> a
getConst) g (Const Int)
start)
next :: forall (f :: * -> *) a. f a -> State Int (Const Int a)
next f a
_ = do {Int
i <- StateT Int Identity Int
forall (m :: * -> *) s. Monad m => StateT s m s
State.get; let {i' :: Int
i' = Int -> Int
forall a. Enum a => a -> a
succ Int
i}; Int -> StateT Int Identity () -> StateT Int Identity ()
forall a b. a -> b -> b
seq Int
i' (Int -> StateT Int Identity ()
forall (m :: * -> *) s. Monad m => s -> StateT s m ()
State.put Int
i'); Const Int a -> State Int (Const Int a)
forall a. a -> StateT Int Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> Const Int a
forall {k} a (b :: k). a -> Const a b
Const Int
i)}
instance Functor (p g s) => Functor (Fixed p g s) where
fmap :: forall a b. (a -> b) -> Fixed p g s a -> Fixed p g s b
fmap a -> b
f (PositiveDirectParser p g s a
p) = p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser ((a -> b) -> p g s a -> p g s b
forall a b. (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f p g s a
p)
fmap a -> b
f p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s b
complete= (a -> b) -> p g s a -> p g s b
forall a b. (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s b
direct0= (a -> b) -> p g s a -> p g s b
forall a b. (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= (a -> b) -> p g s a -> p g s b
forall a b. (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
fmap a -> b
f p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p{
complete= fmap f (complete p),
direct= fmap f (direct p),
direct0= fmap f (direct0 p),
direct1= fmap f (direct1 p),
indirect= fmap f (indirect p),
choices= fmap f <$> choices p,
isAmbiguous= Nothing}
{-# INLINABLE fmap #-}
instance (Rank2.Apply g, Alternative (p g s)) => Applicative (Fixed p g s) where
pure :: forall a. a -> Fixed p g s a
pure a
a = DirectParser{complete :: p g s a
complete= a -> p g s a
forall a. a -> p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a,
direct0 :: p g s a
direct0= a -> p g s a
forall a. a -> p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a,
direct1 :: p g s a
direct1= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
p :: Fixed p g s (a -> b)
p@PositiveDirectParser{} <*> :: forall a b. Fixed p g s (a -> b) -> Fixed p g s a -> Fixed p g s b
<*> Fixed p g s a
q = PositiveDirectParser{
complete :: p g s b
complete= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s (a -> b)
p@DirectParser{} <*> q :: Fixed p g s a
q@PositiveDirectParser{} = PositiveDirectParser{
complete :: p g s b
complete= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s (a -> b)
p@DirectParser{} <*> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s b
complete= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s b
direct0= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s b
direct1= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
Fixed p g s (a -> b)
p <*> q :: Fixed p g s a
q@Parser{} = Fixed p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct :: p g s b
direct= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
q p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s b
direct0= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s b
direct1= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
indirect :: p g s b
indirect= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
q p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
choices :: ChoiceTree (Fixed p g s b)
choices= ChoiceTree (Fixed p g s b)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= Maybe (AmbiguityWitness b)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
pcd :: ParserFlags g
pcd@(ParserFlags Bool
pn Dependencies g
pd) = Fixed p g s (a -> b) -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s (a -> b)
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q g (Const (ParserFlags g))
deps
in if Bool
pn
then Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
qn (Dependencies g -> Dependencies g -> Dependencies g
forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)
else ParserFlags g
pcd}
where p' :: Fixed p g s (a -> b)
p'@Parser{} = Fixed p g s (a -> b) -> Fixed p g s (a -> b)
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s (a -> b)
p
Fixed p g s (a -> b)
p <*> Fixed p g s a
q = Fixed p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct :: p g s b
direct= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct0 :: p g s b
direct0= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q',
direct1 :: p g s b
direct1= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q' p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
indirect :: p g s b
indirect= Fixed p g s (a -> b) -> p g s (a -> b)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s (a -> b)
p' p g s (a -> b) -> p g s a -> p g s b
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
choices :: ChoiceTree (Fixed p g s b)
choices= ChoiceTree (Fixed p g s b)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= Maybe (AmbiguityWitness b)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
pcd :: ParserFlags g
pcd@(ParserFlags Bool
pn Dependencies g
pd) = Fixed p g s (a -> b) -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s (a -> b)
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q' g (Const (ParserFlags g))
deps
in if Bool
pn
then Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
qn (Dependencies g -> Dependencies g -> Dependencies g
forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)
else ParserFlags g
pcd}
where p' :: Fixed p g s (a -> b)
p'@Parser{} = Fixed p g s (a -> b) -> Fixed p g s (a -> b)
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s (a -> b)
p
q' :: Fixed p g s a
q'@Parser{} = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s a
q
{-# INLINABLE pure #-}
{-# INLINABLE (<*>) #-}
instance (Rank2.Apply g, Alternative (p g s)) => Alternative (Fixed p g s) where
empty :: forall a. Fixed p g s a
empty = PositiveDirectParser{complete :: p g s a
complete= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
p :: Fixed p g s a
p@PositiveDirectParser{} <|> :: forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
<|> q :: Fixed p g s a
q@PositiveDirectParser{} = PositiveDirectParser{complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s a
p@PositiveDirectParser{} <|> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q}
p :: Fixed p g s a
p@DirectParser{} <|> q :: Fixed p g s a
q@PositiveDirectParser{} = DirectParser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s a
p@DirectParser{} <|> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q}
Fixed p g s a
p <|> Fixed p g s a
q = Parser{complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct :: p g s a
direct= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
q',
direct0 :: p g s a
direct0= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q',
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q',
indirect :: p g s a
indirect= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
q',
choices :: ChoiceTree (Fixed p g s a)
choices= Fixed p g s a -> ChoiceTree (Fixed p g s a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p' ChoiceTree (Fixed p g s a)
-> ChoiceTree (Fixed p g s a) -> ChoiceTree (Fixed p g s a)
forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
`SymmetricChoice` Fixed p g s a -> ChoiceTree (Fixed p g s a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
q',
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
ParserFlags Bool
pn Dependencies g
pd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q' g (Const (ParserFlags g))
deps
in Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags (Bool
pn Bool -> Bool -> Bool
|| Bool
qn) (Dependencies g -> Dependencies g -> Dependencies g
forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)}
where p' :: Fixed p g s a
p'@Parser{} = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
p
q' :: Fixed p g s a
q'@Parser{} = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
q
many :: forall a. Fixed p g s a -> Fixed p g s [a]
many (PositiveDirectParser p g s a
p) = DirectParser{
complete :: p g s [a]
complete= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many p g s a
p,
direct0 :: p g s [a]
direct0= [a] -> p g s [a]
forall a. a -> p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [],
direct1 :: p g s [a]
direct1= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some p g s a
p}
many p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s [a]
complete= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s [a]
direct0= [a] -> p g s [a]
forall a. a -> p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [] p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[]) (a -> [a]) -> p g s a -> p g s [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s [a]
direct1= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
many p :: Fixed p g s a
p@Parser{} = Fixed p g s [a] -> Fixed p g s [a]
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s [a]
complete= p g s [a]
mcp,
direct :: p g s [a]
direct= p g s [a]
d0 p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s [a]
d1,
direct0 :: p g s [a]
direct0= p g s [a]
d0,
direct1 :: p g s [a]
direct1= p g s [a]
d1,
indirect :: p g s [a]
indirect= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp,
choices :: ChoiceTree (Fixed p g s [a])
choices= ChoiceTree (Fixed p g s [a])
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness [a])
isAmbiguous= Maybe (AmbiguityWitness [a])
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable= True}}
where d0 :: p g s [a]
d0 = [a] -> p g s [a]
forall a. a -> p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [] p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[]) (a -> [a]) -> p g s a -> p g s [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p
d1 :: p g s [a]
d1 = (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp
mcp :: p g s [a]
mcp = p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
some :: forall a. Fixed p g s a -> Fixed p g s [a]
some (PositiveDirectParser p g s a
p) = PositiveDirectParser{complete :: p g s [a]
complete= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some p g s a
p}
some p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s [a]
complete= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s [a]
direct0= (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[]) (a -> [a]) -> p g s a -> p g s [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s [a]
direct1= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
some p :: Fixed p g s a
p@Parser{} = Fixed p g s [a] -> Fixed p g s [a]
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s [a]
complete= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s [a]
direct= p g s [a]
d0 p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s [a]
d1,
direct0 :: p g s [a]
direct0= p g s [a]
d0,
direct1 :: p g s [a]
direct1= p g s [a]
d1,
indirect :: p g s [a]
indirect= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s [a])
choices= ChoiceTree (Fixed p g s [a])
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness [a])
isAmbiguous= Maybe (AmbiguityWitness [a])
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
where d0 :: p g s [a]
d0 = (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[]) (a -> [a]) -> p g s a -> p g s [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p
d1 :: p g s [a]
d1= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
{-# INLINABLE (<|>) #-}
{-# INLINABLE many #-}
{-# INLINABLE some #-}
instance Filterable (p g s) => Filterable (Fixed p g s) where
mapMaybe :: forall a b. (a -> Maybe b) -> Fixed p g s a -> Fixed p g s b
mapMaybe a -> Maybe b
f (PositiveDirectParser p g s a
p) = p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser ((a -> Maybe b) -> p g s a -> p g s b
forall a b. (a -> Maybe b) -> p g s a -> p g s b
forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f p g s a
p)
mapMaybe a -> Maybe b
f p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s b
complete= (a -> Maybe b) -> p g s a -> p g s b
forall a b. (a -> Maybe b) -> p g s a -> p g s b
forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s b
direct0= (a -> Maybe b) -> p g s a -> p g s b
forall a b. (a -> Maybe b) -> p g s a -> p g s b
forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s b
direct1= (a -> Maybe b) -> p g s a -> p g s b
forall a b. (a -> Maybe b) -> p g s a -> p g s b
forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe a -> Maybe b
f (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
mapMaybe a -> Maybe b
f p :: Fixed p g s a
p@Parser{} = Fixed p g s a
p{
complete= mapMaybe f (complete p),
direct= mapMaybe f (direct p),
direct0= mapMaybe f (direct0 p),
direct1= mapMaybe f (direct1 p),
indirect= mapMaybe f (indirect p),
choices= mapMaybe f <$> choices p,
isAmbiguous= Nothing}
{-# INLINABLE mapMaybe #-}
complement :: Const Bool x -> Const Bool x
complement :: forall x. Const Bool x -> Const Bool x
complement (Const Bool
a) = Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Bool
not Bool
a)
intersection :: Const Bool x -> Const Bool x -> Const Bool x
intersection :: forall a. Const Bool a -> Const Bool a -> Const Bool a
intersection (Const Bool
True) Const Bool x
x = Const Bool x
x
intersection (Const Bool
False) Const Bool x
_ = Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const Bool
False
union :: Const Bool x -> Const Bool x -> Const Bool x
union :: forall a. Const Bool a -> Const Bool a -> Const Bool a
union (Const Bool
False) Const Bool x
x = Const Bool x
x
union (Const Bool
True) Const Bool x
_ = Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const Bool
True
depUnion :: Rank2.Apply g => Dependencies g -> Dependencies g -> Dependencies g
depUnion :: forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion (StaticDependencies g (Const Bool)
d1) (StaticDependencies g (Const Bool)
d2) = g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies ((forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
union g (Const Bool)
d1 g (Const Bool)
d2)
depUnion Dependencies g
_ Dependencies g
_ = Dependencies g
forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
instance (Rank2.Apply g, Alternative (p g s), Monad (p g s)) => Monad (Fixed p g s) where
return :: forall a. a -> Fixed p g s a
return = a -> Fixed p g s a
forall a. a -> Fixed p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
>> :: forall a b. Fixed p g s a -> Fixed p g s b -> Fixed p g s b
(>>) = Fixed p g s a -> Fixed p g s b -> Fixed p g s b
forall a b. Fixed p g s a -> Fixed p g s b -> Fixed p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
PositiveDirectParser p g s a
p >>= :: forall a b. Fixed p g s a -> (a -> Fixed p g s b) -> Fixed p g s b
>>= a -> Fixed p g s b
cont = p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont)
p :: Fixed p g s a
p@DirectParser{} >>= a -> Fixed p g s b
cont = Fixed p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont,
direct :: p g s b
direct= p g s b
d0 p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s b
d1,
direct0 :: p g s b
direct0= p g s b
d0,
direct1 :: p g s b
direct1= p g s b
d1,
indirect :: p g s b
indirect= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s b -> Fixed p g s b
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' (Fixed p g s b -> Fixed p g s b)
-> (a -> Fixed p g s b) -> a -> Fixed p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont,
choices :: ChoiceTree (Fixed p g s b)
choices= ChoiceTree (Fixed p g s b)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= Maybe (AmbiguityWitness b)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= ParserFlags g -> g (Const (ParserFlags g)) -> ParserFlags g
forall a b. a -> b -> a
const (Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True Dependencies g
forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies)}
where d0 :: p g s b
d0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s b -> Fixed p g s b
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' (Fixed p g s b -> Fixed p g s b)
-> (a -> Fixed p g s b) -> a -> Fixed p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont
d1 :: p g s b
d1 = (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s b -> Fixed p g s b
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' (Fixed p g s b -> Fixed p g s b)
-> (a -> Fixed p g s b) -> a -> Fixed p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont) p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont)
Fixed p g s a
p >>= a -> Fixed p g s b
cont = Fixed p g s b -> Fixed p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s b
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont,
direct :: p g s b
direct= p g s b
d0 p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> p g s b
d1,
direct0 :: p g s b
direct0= p g s b
d0,
direct1 :: p g s b
direct1= p g s b
d1,
indirect :: p g s b
indirect= (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont) p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s b -> Fixed p g s b
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' (Fixed p g s b -> Fixed p g s b)
-> (a -> Fixed p g s b) -> a -> Fixed p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont),
choices :: ChoiceTree (Fixed p g s b)
choices= ChoiceTree (Fixed p g s b)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness b)
isAmbiguous= Maybe (AmbiguityWitness b)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
cd->
let pcd :: ParserFlags g
pcd@(ParserFlags Bool
pn Dependencies g
_) = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p' g (Const (ParserFlags g))
cd
in if Bool
pn
then Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True Dependencies g
forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
else ParserFlags g
pcd}
where d0 :: p g s b
d0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s b -> Fixed p g s b
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' (Fixed p g s b -> Fixed p g s b)
-> (a -> Fixed p g s b) -> a -> Fixed p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont
d1 :: p g s b
d1 = (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s b -> Fixed p g s b
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' (Fixed p g s b -> Fixed p g s b)
-> (a -> Fixed p g s b) -> a -> Fixed p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont) p g s b -> p g s b -> p g s b
forall a. p g s a -> p g s a -> p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> (a -> p g s b) -> p g s b
forall a b. p g s a -> (a -> p g s b) -> p g s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Fixed p g s b -> p g s b
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete (Fixed p g s b -> p g s b) -> (a -> Fixed p g s b) -> a -> p g s b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Fixed p g s b
cont)
p' :: Fixed p g s a
p'@Parser{} = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general' Fixed p g s a
p
#if MIN_VERSION_base(4,13,0)
instance (Rank2.Apply g, Alternative (p g s), MonadFail (p g s)) => MonadFail (Fixed p g s) where
#endif
fail :: forall a. String -> Fixed p g s a
fail String
msg = PositiveDirectParser{complete :: p g s a
complete= String -> p g s a
forall a. String -> p g s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
msg}
instance (Rank2.Apply g, MonadPlus (p g s)) => MonadPlus (Fixed p g s) where
mzero :: forall a. Fixed p g s a
mzero = Fixed p g s a
forall a. Fixed p g s a
forall (f :: * -> *) a. Alternative f => f a
empty
mplus :: forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
mplus = Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
instance (Rank2.Apply g, Alternative (p g s), Semigroup x) => Semigroup (Fixed p g s x) where
<> :: Fixed p g s x -> Fixed p g s x -> Fixed p g s x
(<>) = (x -> x -> x) -> Fixed p g s x -> Fixed p g s x -> Fixed p g s x
forall a b c.
(a -> b -> c) -> Fixed p g s a -> Fixed p g s b -> Fixed p g s c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 x -> x -> x
forall a. Semigroup a => a -> a -> a
(<>)
instance (Rank2.Apply g, Alternative (p g s), Monoid x) => Monoid (Fixed p g s x) where
mempty :: Fixed p g s x
mempty = x -> Fixed p g s x
forall a. a -> Fixed p g s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure x
forall a. Monoid a => a
mempty
mappend :: Fixed p g s x -> Fixed p g s x -> Fixed p g s x
mappend = Fixed p g s x -> Fixed p g s x -> Fixed p g s x
forall a. Semigroup a => a -> a -> a
(<>)
primitive :: p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive p g s a
d0 p g s a
d1 p g s a
d = DirectParser{complete :: p g s a
complete= p g s a
d,
direct0 :: p g s a
direct0= p g s a
d0,
direct1 :: p g s a
direct1= p g s a
d1}
{-# INLINE primitive #-}
liftPositive :: p g s a -> Fixed p g s a
liftPositive :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive p g s a
p = PositiveDirectParser{complete :: p g s a
complete= p g s a
p}
{-# INLINE liftPositive #-}
liftPure :: Alternative (p g s) => p g s a -> Fixed p g s a
liftPure :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Alternative (p g s) =>
p g s a -> Fixed p g s a
liftPure p g s a
p = DirectParser{complete :: p g s a
complete= p g s a
p,
direct0 :: p g s a
direct0= p g s a
p,
direct1 :: p g s a
direct1= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
{-# INLINE liftPure #-}
instance (Rank2.Apply g, Parsing (p g s), InputParsing (Fixed p g s)) => Parsing (Fixed p g s) where
eof :: Fixed p g s ()
eof = p g s () -> p g s () -> p g s () -> Fixed p g s ()
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive p g s ()
forall (m :: * -> *). Parsing m => m ()
eof p g s ()
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty p g s ()
forall (m :: * -> *). Parsing m => m ()
eof
try :: forall a. Fixed p g s a -> Fixed p g s a
try (PositiveDirectParser p g s a
p) = p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> m a
try p g s a
p)
try p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s a
complete= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> m a
try (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> m a
try (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s a
direct1= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> m a
try (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
try p :: Fixed p g s a
p@Parser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Fixed p g s a
p{
complete= try (complete p),
direct= try (direct p),
direct0= try (direct0 p),
direct1= try (direct1 p),
indirect= try (indirect p)}
PositiveDirectParser p g s a
p <?> :: forall a. Fixed p g s a -> String -> Fixed p g s a
<?> String
msg = p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a
p p g s a -> String -> p g s a
forall a. p g s a -> String -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg)
p :: Fixed p g s a
p@DirectParser{} <?> String
msg = DirectParser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> String -> p g s a
forall a. p g s a -> String -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct0 :: p g s a
direct0= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> String -> p g s a
forall a. p g s a -> String -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> String -> p g s a
forall a. p g s a -> String -> p g s a
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
msg}
p :: Fixed p g s a
p@Parser{} <?> String
msg = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Fixed p g s a
p{
complete= complete p <?> msg,
direct= direct p <?> msg,
direct0= direct0 p <?> msg,
direct1= direct1 p <?> msg,
indirect= indirect p <?> msg}
notFollowedBy :: forall a. Show a => Fixed p g s a -> Fixed p g s ()
notFollowedBy p :: Fixed p g s a
p@PositiveDirectParser{} = DirectParser{
complete :: p g s ()
complete= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s ()
direct0= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s ()
direct1= p g s ()
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
notFollowedBy p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s ()
complete= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s ()
direct0= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s ()
direct1= p g s ()
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
notFollowedBy p :: Fixed p g s a
p@Parser{} = Fixed p g s () -> Fixed p g s ()
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s ()
complete= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s ()
direct= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s ()
direct0= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct1 :: p g s ()
direct1= p g s ()
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
indirect :: p g s ()
indirect= p g s a -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s ())
choices= ChoiceTree (Fixed p g s ())
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness ())
isAmbiguous= Maybe (AmbiguityWitness ())
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable= True}}
unexpected :: forall a. String -> Fixed p g s a
unexpected String
msg = p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (String -> p g s a
forall a. String -> p g s a
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
msg)
instance (Rank2.Apply g, InputParsing (Fixed p g s), DeterministicParsing (p g s)) =>
DeterministicParsing (Fixed p g s) where
p :: Fixed p g s a
p@DirectParser{} <<|> :: forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
<<|> q :: Fixed p g s a
q@PositiveDirectParser{} = DirectParser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q}
p :: Fixed p g s a
p@DirectParser{} <<|> q :: Fixed p g s a
q@DirectParser{} = DirectParser{
complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q,
direct0 :: p g s a
direct0 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q,
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q}
Fixed p g s a
p <<|> Fixed p g s a
q = Parser{complete :: p g s a
complete= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
q',
direct :: p g s a
direct= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') p g s () -> p g s a -> p g s a
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
q',
direct0 :: p g s a
direct0= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') p g s () -> p g s a -> p g s a
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
q',
direct1 :: p g s a
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') p g s () -> p g s a -> p g s a
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
q',
indirect :: p g s a
indirect= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p' p g s a -> p g s a -> p g s a
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p') p g s () -> p g s a -> p g s a
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
q',
choices :: ChoiceTree (Fixed p g s a)
choices= Fixed p g s a -> ChoiceTree (Fixed p g s a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
p' ChoiceTree (Fixed p g s a)
-> ChoiceTree (Fixed p g s a) -> ChoiceTree (Fixed p g s a)
forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
`LeftBiasedChoice` Fixed p g s a -> ChoiceTree (Fixed p g s a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices Fixed p g s a
q',
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> let
ParserFlags Bool
pn Dependencies g
pd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p' g (Const (ParserFlags g))
deps
ParserFlags Bool
qn Dependencies g
qd = Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
q' g (Const (ParserFlags g))
deps
in Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags (Bool
pn Bool -> Bool -> Bool
|| Bool
qn) (Dependencies g -> Dependencies g -> Dependencies g
forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
pd Dependencies g
qd)}
where p' :: Fixed p g s a
p'@Parser{} = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
p
q' :: Fixed p g s a
q'@Parser{} = Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general Fixed p g s a
q
takeSome :: forall a. Fixed p g s a -> Fixed p g s [a]
takeSome Fixed p g s a
p = (:) (a -> [a] -> [a]) -> Fixed p g s a -> Fixed p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a
p Fixed p g s ([a] -> [a]) -> Fixed p g s [a] -> Fixed p g s [a]
forall a b. Fixed p g s (a -> b) -> Fixed p g s a -> Fixed p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Fixed p g s a -> Fixed p g s [a]
forall a. Fixed p g s a -> Fixed p g s [a]
forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany Fixed p g s a
p
takeMany :: forall a. Fixed p g s a -> Fixed p g s [a]
takeMany (PositiveDirectParser p g s a
p) = DirectParser{
complete :: p g s [a]
complete = p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany p g s a
p,
direct0 :: p g s [a]
direct0= [] [a] -> p g s () -> p g s [a]
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void p g s a
p),
direct1 :: p g s [a]
direct1= p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome p g s a
p}
takeMany p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s [a]
complete = p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s [a]
direct0= (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[]) (a -> [a]) -> p g s a -> p g s [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> [] [a] -> p g s () -> p g s [a]
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s [a]
direct1= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
takeMany p :: Fixed p g s a
p@Parser{} = Fixed p g s [a] -> Fixed p g s [a]
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s [a]
complete= p g s [a]
mcp,
direct :: p g s [a]
direct= p g s [a]
d1 p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s [a]
d0,
direct0 :: p g s [a]
direct0= p g s [a]
d0,
direct1 :: p g s [a]
direct1= p g s [a]
d1,
indirect :: p g s [a]
indirect= (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp,
choices :: ChoiceTree (Fixed p g s [a])
choices= ChoiceTree (Fixed p g s [a])
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness [a])
isAmbiguous= Maybe (AmbiguityWitness [a])
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable= True}}
where d0 :: p g s [a]
d0 = (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[]) (a -> [a]) -> p g s a -> p g s [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s [a] -> p g s [a] -> p g s [a]
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> [] [a] -> p g s () -> p g s [a]
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p)
d1 :: p g s [a]
d1 = (:) (a -> [a] -> [a]) -> p g s a -> p g s ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s ([a] -> [a]) -> p g s [a] -> p g s [a]
forall a b. p g s (a -> b) -> p g s a -> p g s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> p g s [a]
mcp
mcp :: p g s [a]
mcp = p g s a -> p g s [a]
forall a. p g s a -> p g s [a]
forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
skipAll :: forall a. Fixed p g s a -> Fixed p g s ()
skipAll (PositiveDirectParser p g s a
p) = DirectParser{
complete :: p g s ()
complete = p g s a -> p g s ()
forall a. p g s a -> p g s ()
forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll p g s a
p,
direct0 :: p g s ()
direct0= () () -> p g s () -> p g s ()
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void p g s a
p),
direct1 :: p g s ()
direct1= p g s a
p p g s a -> p g s () -> p g s ()
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s a -> p g s ()
forall a. p g s a -> p g s ()
forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll p g s a
p}
skipAll p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s ()
complete = p g s a -> p g s ()
forall a. p g s a -> p g s ()
forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s ()
direct0= p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p) p g s () -> p g s () -> p g s ()
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s ()
direct1= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> p g s () -> p g s ()
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s a -> p g s ()
forall a. p g s a -> p g s ()
forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)}
skipAll p :: Fixed p g s a
p@Parser{} = Fixed p g s () -> Fixed p g s ()
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s ()
complete= p g s ()
mcp,
direct :: p g s ()
direct= p g s ()
d1 p g s () -> p g s () -> p g s ()
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s ()
d0,
direct0 :: p g s ()
direct0= p g s ()
d0,
direct1 :: p g s ()
direct1= p g s ()
d1,
indirect :: p g s ()
indirect= Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p p g s a -> p g s () -> p g s ()
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s ()
mcp,
choices :: ChoiceTree (Fixed p g s ())
choices= ChoiceTree (Fixed p g s ())
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness ())
isAmbiguous= Maybe (AmbiguityWitness ())
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable= True}}
where d0 :: p g s ()
d0 = () () -> p g s a -> p g s ()
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p p g s () -> p g s () -> p g s ()
forall a. p g s a -> p g s a -> p g s a
forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> p g s () -> p g s ()
forall a. Show a => p g s a -> p g s ()
forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (p g s a -> p g s ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (p g s a -> p g s ()) -> p g s a -> p g s ()
forall a b. (a -> b) -> a -> b
$ Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p)
d1 :: p g s ()
d1 = Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p p g s a -> p g s () -> p g s ()
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s ()
mcp
mcp :: p g s ()
mcp = p g s a -> p g s ()
forall a. p g s a -> p g s ()
forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
instance (Rank2.Apply g, CommittedParsing (p g s), CommittedResults (p g s) ~ ParseResults s) =>
CommittedParsing (Fixed p g s) where
type CommittedResults (Fixed p g s) = ParseResults s
commit :: forall a.
Fixed p g s a -> Fixed p g s (CommittedResults (Fixed p g s) a)
commit (PositiveDirectParser p g s a
p) = p g s (Either (ParseFailure Pos s) a)
-> Fixed p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit p g s a
p)
commit p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s (Either (ParseFailure Pos s) a)
complete = p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s (Either (ParseFailure Pos s) a)
direct0= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Either (ParseFailure Pos s) a)
direct1= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
commit p :: Fixed p g s a
p@Parser{} = Fixed p g s (Either (ParseFailure Pos s) a)
-> Fixed p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s (Either (ParseFailure Pos s) a)
complete= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s (Either (ParseFailure Pos s) a)
direct= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s (Either (ParseFailure Pos s) a)
direct0= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Either (ParseFailure Pos s) a)
direct1= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s (Either (ParseFailure Pos s) a)
indirect= p g s a -> p g s (CommittedResults (p g s) a)
forall a. p g s a -> p g s (CommittedResults (p g s) a)
forall (m :: * -> *) a.
CommittedParsing m =>
m a -> m (CommittedResults m a)
commit (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s (Either (ParseFailure Pos s) a))
choices= ChoiceTree (Fixed p g s (Either (ParseFailure Pos s) a))
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness (Either (ParseFailure Pos s) a))
isAmbiguous= Maybe (AmbiguityWitness (Either (ParseFailure Pos s) a))
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
admit :: Fixed p g s (CommittedResults (Fixed p g s) a) -> Fixed p g s a
admit :: forall a.
Fixed p g s (CommittedResults (Fixed p g s) a) -> Fixed p g s a
admit (PositiveDirectParser p g s (CommittedResults (Fixed p g s) a)
p) = p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit p g s (CommittedResults (p g s) a)
p g s (CommittedResults (Fixed p g s) a)
p)
admit p :: Fixed p g s (CommittedResults (Fixed p g s) a)
p@DirectParser{} = DirectParser{
complete :: p g s a
complete = p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct0 :: p g s a
direct0= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct1 :: p g s a
direct1= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p)}
admit p :: Fixed p g s (CommittedResults (Fixed p g s) a)
p@Parser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct :: p g s a
direct= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct0 :: p g s a
direct0= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
direct1 :: p g s a
direct1= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
indirect :: p g s a
indirect= p g s (CommittedResults (p g s) a) -> p g s a
forall a. p g s (CommittedResults (p g s) a) -> p g s a
forall (m :: * -> *) a.
CommittedParsing m =>
m (CommittedResults m a) -> m a
admit (Fixed p g s (Either (ParseFailure Pos s) a)
-> p g s (Either (ParseFailure Pos s) a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p),
choices :: ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Maybe (AmbiguityWitness a)
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s (Either (ParseFailure Pos s) a)
-> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s (Either (ParseFailure Pos s) a)
Fixed p g s (CommittedResults (Fixed p g s) a)
p}
instance (Rank2.Apply g, LookAheadParsing (p g s), InputParsing (Fixed p g s)) => LookAheadParsing (Fixed p g s) where
lookAhead :: forall a. Fixed p g s a -> Fixed p g s a
lookAhead p :: Fixed p g s a
p@PositiveDirectParser{} = DirectParser{
complete :: p g s a
complete= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s a
direct1= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
lookAhead p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s a
complete= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s a
direct0= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct1 :: p g s a
direct1= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}
lookAhead p :: Fixed p g s a
p@Parser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s a
complete= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s a
direct= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s a
direct0= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct1 :: p g s a
direct1= p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty,
isAmbiguous :: Maybe (AmbiguityWitness a)
isAmbiguous= Fixed p g s a -> Maybe (AmbiguityWitness a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
p,
indirect :: p g s a
indirect= p g s a -> p g s a
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
forall a. HasCallStack => a
undefined,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= \g (Const (ParserFlags g))
deps-> (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p g (Const (ParserFlags g))
deps){nullable= True}}
instance (Rank2.Apply g, LeftReductive s, FactorialMonoid s, InputParsing (p g s), ParserInput (p g s) ~ s) =>
InputParsing (Fixed p g s) where
type ParserInput (Fixed p g s) = s
getInput :: Fixed p g s (ParserInput (Fixed p g s))
getInput = p g s s -> p g s s -> p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive p g s s
p g s (ParserInput (p g s))
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput p g s s
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty p g s s
p g s (ParserInput (p g s))
forall (m :: * -> *). InputParsing m => m (ParserInput m)
getInput
anyToken :: Fixed p g s (ParserInput (Fixed p g s))
anyToken = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive p g s s
p g s (ParserInput (p g s))
forall (m :: * -> *). InputParsing m => m (ParserInput m)
anyToken
satisfy :: (ParserInput (Fixed p g s) -> Bool)
-> Fixed p g s (ParserInput (Fixed p g s))
satisfy ParserInput (Fixed p g s) -> Bool
predicate = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive ((ParserInput (p g s) -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate)
notSatisfy :: (ParserInput (Fixed p g s) -> Bool) -> Fixed p g s ()
notSatisfy ParserInput (Fixed p g s) -> Bool
predicate = p g s () -> p g s () -> p g s () -> Fixed p g s ()
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive ((ParserInput (p g s) -> Bool) -> p g s ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate) p g s ()
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty ((ParserInput (p g s) -> Bool) -> p g s ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate)
scan :: forall state.
state
-> (state -> ParserInput (Fixed p g s) -> Maybe state)
-> Fixed p g s (ParserInput (Fixed p g s))
scan state
s0 state -> ParserInput (Fixed p g s) -> Maybe state
f = p g s s -> p g s s -> p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (s
forall a. Monoid a => a
mempty s -> p g s () -> p g s s
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParserInput (p g s) -> Bool) -> p g s ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy s -> Bool
ParserInput (p g s) -> Bool
test) (p g s s -> p g s s
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead ((ParserInput (p g s) -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
satisfy s -> Bool
ParserInput (p g s) -> Bool
test) p g s s -> p g s s -> p g s s
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s s
p g s (ParserInput (p g s))
p) p g s s
p g s (ParserInput (p g s))
p
where p :: p g s (ParserInput (p g s))
p = state
-> (state -> ParserInput (p g s) -> Maybe state)
-> p g s (ParserInput (p g s))
forall state.
state
-> (state -> ParserInput (p g s) -> Maybe state)
-> p g s (ParserInput (p g s))
forall (m :: * -> *) state.
InputParsing m =>
state
-> (state -> ParserInput m -> Maybe state) -> m (ParserInput m)
scan state
s0 state -> ParserInput (p g s) -> Maybe state
state -> ParserInput (Fixed p g s) -> Maybe state
f
test :: s -> Bool
test = Maybe state -> Bool
forall a. Maybe a -> Bool
isJust (Maybe state -> Bool) -> (s -> Maybe state) -> s -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. state -> ParserInput (Fixed p g s) -> Maybe state
f state
s0
string :: ParserInput (Fixed p g s)
-> Fixed p g s (ParserInput (Fixed p g s))
string ParserInput (Fixed p g s)
s
| s -> Bool
forall m. MonoidNull m => m -> Bool
null s
ParserInput (Fixed p g s)
s = p g s s -> p g s s -> p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (ParserInput (p g s) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string ParserInput (p g s)
ParserInput (Fixed p g s)
s) p g s s
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty (ParserInput (p g s) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string ParserInput (p g s)
ParserInput (Fixed p g s)
s)
| Bool
otherwise = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (ParserInput (p g s) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string ParserInput (p g s)
ParserInput (Fixed p g s)
s)
take :: Int -> Fixed p g s (ParserInput (Fixed p g s))
take Int
0 = Fixed p g s s
Fixed p g s (ParserInput (Fixed p g s))
forall a. Monoid a => a
mempty
take Int
n = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive (Int -> p g s (ParserInput (p g s))
forall (m :: * -> *). InputParsing m => Int -> m (ParserInput m)
take Int
n)
takeWhile :: (ParserInput (Fixed p g s) -> Bool)
-> Fixed p g s (ParserInput (Fixed p g s))
takeWhile ParserInput (Fixed p g s) -> Bool
predicate = p g s s -> p g s s -> p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (s
forall a. Monoid a => a
mempty s -> p g s () -> p g s s
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParserInput (p g s) -> Bool) -> p g s ()
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m ()
notSatisfy ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate)
((ParserInput (p g s) -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1 ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate) ((ParserInput (p g s) -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate)
takeWhile1 :: (ParserInput (Fixed p g s) -> Bool)
-> Fixed p g s (ParserInput (Fixed p g s))
takeWhile1 ParserInput (Fixed p g s) -> Bool
predicate = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive ((ParserInput (p g s) -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputParsing m =>
(ParserInput m -> Bool) -> m (ParserInput m)
takeWhile1 ParserInput (p g s) -> Bool
ParserInput (Fixed p g s) -> Bool
predicate)
{-# INLINABLE string #-}
instance (Rank2.Apply g, LeftReductive s, FactorialMonoid s, Show s,
TraceableParsing (p g s), ParserInput (p g s) ~ s) =>
TraceableParsing (Fixed p g s) where
traceInput :: forall a.
(ParserInput (Fixed p g s) -> String)
-> Fixed p g s a -> Fixed p g s a
traceInput ParserInput (Fixed p g s) -> String
description p :: Fixed p g s a
p@PositiveDirectParser{} = Fixed p g s a
p{
complete= traceInput (\ParserInput (p g s)
s-> String
"direct+ " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
ParserInput (Fixed p g s)
s) (complete p)}
traceInput ParserInput (Fixed p g s) -> String
description p :: Fixed p g s a
p@DirectParser{} = Fixed p g s a
p{
complete= traceInput (\ParserInput (p g s)
s-> String
"direct " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
ParserInput (Fixed p g s)
s) (complete p),
direct0= traceInput (\ParserInput (p g s)
s-> String
"direct0 " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
ParserInput (Fixed p g s)
s) (direct0 p),
direct1= traceInput (\ParserInput (p g s)
s-> String
"direct1 " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
ParserInput (Fixed p g s)
s) (direct1 p)}
traceInput ParserInput (Fixed p g s) -> String
description p :: Fixed p g s a
p@Parser{} = Fixed p g s a -> Fixed p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Fixed p g s a
p{
complete= traceBy "complete" (complete p),
direct= traceBy "direct" (direct p),
direct0= traceBy "direct0" (direct0 p),
direct1= traceBy "direct1" (direct1 p),
indirect= traceBy "indirect" (indirect p)}
where traceBy :: String -> p g s a -> p g s a
traceBy String
mode = (ParserInput (p g s) -> String) -> p g s a -> p g s a
forall a. (ParserInput (p g s) -> String) -> p g s a -> p g s a
forall (m :: * -> *) a.
TraceableParsing m =>
(ParserInput m -> String) -> m a -> m a
traceInput (\ParserInput (p g s)
s-> String
"(" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
mode String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
") " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ParserInput (Fixed p g s) -> String
description ParserInput (p g s)
ParserInput (Fixed p g s)
s)
instance (Rank2.Apply g, LeftReductive s, FactorialMonoid s,
ConsumedInputParsing (p g s), ParserInput (p g s) ~ s) => ConsumedInputParsing (Fixed p g s) where
match :: forall a.
Fixed p g s a -> Fixed p g s (ParserInput (Fixed p g s), a)
match (PositiveDirectParser p g s a
p) = p g s (s, a) -> Fixed p g s (s, a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match p g s a
p)
match p :: Fixed p g s a
p@DirectParser{} = DirectParser{
complete :: p g s (s, a)
complete= p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s (s, a)
direct0 = p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (s, a)
direct1 = p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
match p :: Fixed p g s a
p@Parser{} = Fixed p g s (s, a) -> Fixed p g s (s, a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s (s, a)
complete= p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s (s, a)
direct = p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s (s, a)
direct0 = p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (s, a)
direct1 = p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s (s, a)
indirect= p g s a -> p g s (ParserInput (p g s), a)
forall a. p g s a -> p g s (ParserInput (p g s), a)
forall (m :: * -> *) a.
ConsumedInputParsing m =>
m a -> m (ParserInput m, a)
match (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s (s, a))
choices= ChoiceTree (Fixed p g s (s, a))
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness (s, a))
isAmbiguous= Maybe (AmbiguityWitness (s, a))
forall a. Maybe a
Nothing,
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
instance (Rank2.Apply g, Show s, TextualMonoid s, InputCharParsing (p g s), ParserInput (p g s) ~ s) =>
InputCharParsing (Fixed p g s) where
satisfyCharInput :: (Char -> Bool) -> Fixed p g s (ParserInput (Fixed p g s))
satisfyCharInput Char -> Bool
predicate = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive ((Char -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
satisfyCharInput Char -> Bool
predicate)
notSatisfyChar :: (Char -> Bool) -> Fixed p g s ()
notSatisfyChar Char -> Bool
predicate = p g s () -> p g s () -> p g s () -> Fixed p g s ()
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive ((Char -> Bool) -> p g s ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
predicate) p g s ()
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty ((Char -> Bool) -> p g s ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
predicate)
scanChars :: forall state.
state
-> (state -> Char -> Maybe state)
-> Fixed p g s (ParserInput (Fixed p g s))
scanChars state
s0 state -> Char -> Maybe state
f = p g s s -> p g s s -> p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (s
forall a. Monoid a => a
mempty s -> p g s () -> p g s s
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (Char -> Bool) -> p g s ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
test) (p g s Char -> p g s Char
forall a. p g s a -> p g s a
forall (m :: * -> *) a. LookAheadParsing m => m a -> m a
lookAhead ((Char -> Bool) -> p g s Char
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
Char.satisfy Char -> Bool
test) p g s Char -> p g s s -> p g s s
forall a b. p g s a -> p g s b -> p g s b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> p g s s
p g s (ParserInput (p g s))
p) p g s s
p g s (ParserInput (p g s))
p
where p :: p g s (ParserInput (p g s))
p = state
-> (state -> Char -> Maybe state) -> p g s (ParserInput (p g s))
forall state.
state
-> (state -> Char -> Maybe state) -> p g s (ParserInput (p g s))
forall (m :: * -> *) state.
InputCharParsing m =>
state -> (state -> Char -> Maybe state) -> m (ParserInput m)
scanChars state
s0 state -> Char -> Maybe state
f
test :: Char -> Bool
test = Maybe state -> Bool
forall a. Maybe a -> Bool
isJust (Maybe state -> Bool) -> (Char -> Maybe state) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. state -> Char -> Maybe state
f state
s0
takeCharsWhile :: (Char -> Bool) -> Fixed p g s (ParserInput (Fixed p g s))
takeCharsWhile Char -> Bool
predicate = p g s s -> p g s s -> p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> p g s a -> p g s a -> Fixed p g s a
primitive (s
forall a. Monoid a => a
mempty s -> p g s () -> p g s s
forall a b. a -> p g s b -> p g s a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (Char -> Bool) -> p g s ()
forall (m :: * -> *). InputCharParsing m => (Char -> Bool) -> m ()
notSatisfyChar Char -> Bool
predicate)
((Char -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1 Char -> Bool
predicate) ((Char -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile Char -> Bool
predicate)
takeCharsWhile1 :: (Char -> Bool) -> Fixed p g s (ParserInput (Fixed p g s))
takeCharsWhile1 Char -> Bool
predicate = p g s s -> Fixed p g s s
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive ((Char -> Bool) -> p g s (ParserInput (p g s))
forall (m :: * -> *).
InputCharParsing m =>
(Char -> Bool) -> m (ParserInput m)
takeCharsWhile1 Char -> Bool
predicate)
instance (Rank2.Apply g, CharParsing (p g s), InputCharParsing (Fixed p g s), TextualMonoid s,
s ~ ParserInput (Fixed p g s), Show s) => CharParsing (Fixed p g s) where
satisfy :: (Char -> Bool) -> Fixed p g s Char
satisfy Char -> Bool
predicate = p g s Char -> Fixed p g s Char
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
liftPositive ((Char -> Bool) -> p g s Char
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
Char.satisfy Char -> Bool
predicate)
string :: String -> Fixed p g s String
string String
s = (s -> String) -> s -> String
forall t. TextualMonoid t => (t -> String) -> t -> String
Textual.toString (String -> s -> String
forall a. HasCallStack => String -> a
error String
"unexpected non-character") (s -> String) -> Fixed p g s s -> Fixed p g s String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserInput (Fixed p g s)
-> Fixed p g s (ParserInput (Fixed p g s))
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string (String -> s
forall a. IsString a => String -> a
fromString String
s)
text :: Text -> Fixed p g s Text
text Text
t = (String -> Text
forall a. IsString a => String -> a
fromString (String -> Text) -> (s -> String) -> s -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> String) -> s -> String
forall t. TextualMonoid t => (t -> String) -> t -> String
Textual.toString (String -> s -> String
forall a. HasCallStack => String -> a
error String
"unexpected non-character")) (s -> Text) -> Fixed p g s s -> Fixed p g s Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserInput (Fixed p g s)
-> Fixed p g s (ParserInput (Fixed p g s))
forall (m :: * -> *).
InputParsing m =>
ParserInput m -> m (ParserInput m)
string (Text -> s
forall t. TextualMonoid t => Text -> t
Textual.fromText Text
t)
instance (AmbiguousParsing (p g s), Rank2.Apply g) => AmbiguousParsing (Fixed p g s) where
ambiguous :: forall a. Fixed p g s a -> Fixed p g s (Ambiguous a)
ambiguous (PositiveDirectParser p g s a
p) = p g s (Ambiguous a) -> Fixed p g s (Ambiguous a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> Fixed p g s a
PositiveDirectParser (p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous p g s a
p)
ambiguous p :: Fixed p g s a
p@DirectParser{} = DirectParser{complete :: p g s (Ambiguous a)
complete= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct0 :: p g s (Ambiguous a)
direct0= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Ambiguous a)
direct1= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p)}
ambiguous p :: Fixed p g s a
p@Parser{} = Fixed p g s (Ambiguous a) -> Fixed p g s (Ambiguous a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Fixed p g s a
asLeaf Parser{
complete :: p g s (Ambiguous a)
complete= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p),
direct :: p g s (Ambiguous a)
direct= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p),
direct0 :: p g s (Ambiguous a)
direct0= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct0 Fixed p g s a
p),
direct1 :: p g s (Ambiguous a)
direct1= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct1 Fixed p g s a
p),
indirect :: p g s (Ambiguous a)
indirect= p g s a -> p g s (Ambiguous a)
forall a. p g s a -> p g s (Ambiguous a)
forall (m :: * -> *) a.
AmbiguousParsing m =>
m a -> m (Ambiguous a)
ambiguous (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p),
choices :: ChoiceTree (Fixed p g s (Ambiguous a))
choices= ChoiceTree (Fixed p g s (Ambiguous a))
forall a. HasCallStack => a
undefined,
isAmbiguous :: Maybe (AmbiguityWitness (Ambiguous a))
isAmbiguous= AmbiguityWitness (Ambiguous a)
-> Maybe (AmbiguityWitness (Ambiguous a))
forall a. a -> Maybe a
Just ((Ambiguous a :~: Ambiguous a) -> AmbiguityWitness (Ambiguous a)
forall a b. (a :~: Ambiguous b) -> AmbiguityWitness a
AmbiguityWitness Ambiguous a :~: Ambiguous a
forall {k} (a :: k). a :~: a
Refl),
cyclicDescendants :: g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants Fixed p g s a
p}
{-# INLINABLE ambiguous #-}
autochain :: forall p g s f rl (cb :: Type -> Type).
(cb ~ Const (g (Const Bool)), f ~ GrammarFunctor (p g s), f ~ rl s,
LeftRecParsing p g s rl, DeterministicParsing (p g s),
Rank2.Apply g, Rank2.Traversable g, Rank2.Distributive g, Rank2.Logistic g)
=> g (Fixed p g s) -> g (Fixed p g s)
autochain :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
(f :: * -> *) (rl :: * -> * -> *) (cb :: * -> *).
(cb ~ Const (g (Const Bool)), f ~ GrammarFunctor (p g s), f ~ rl s,
LeftRecParsing p g s rl, DeterministicParsing (p g s), Apply g,
Traversable g, Distributive g, Logistic g) =>
g (Fixed p g s) -> g (Fixed p g s)
autochain g (Fixed p g s)
g = (forall a.
Compose
((->) (g (Const (g (Const Bool))))) (Const (g (Const Bool))) a
-> (~>) (rl s ~> rl s) (Const (g (rl s) -> g (rl s))) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a)
-> g (Compose
((->) (g (Const (g (Const Bool))))) (Const (g (Const Bool))))
-> g ((rl s ~> rl s) ~> Const (g (rl s) -> g (rl s)))
-> g (Const Bool)
-> g (Fixed p g s)
-> g (Fixed p g s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *) (s :: k -> *) (t :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a -> s a -> t a)
-> g p -> g q -> g r -> g s -> g t
Rank2.liftA4 Compose ((->) (g cb)) cb a
-> Arrow (f ~> f) (Const (g f -> g f)) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
Compose
((->) (g (Const (g (Const Bool))))) (Const (g (Const Bool))) a
-> Arrow (rl s ~> rl s) (Const (g (rl s) -> g (rl s))) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
forall a.
Compose ((->) (g cb)) cb a
-> Arrow (f ~> f) (Const (g f -> g f)) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
forall a.
Compose
((->) (g (Const (g (Const Bool))))) (Const (g (Const Bool))) a
-> (~>) (rl s ~> rl s) (Const (g (rl s) -> g (rl s))) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
optimize g (Compose
((->) (g (Const (g (Const Bool))))) (Const (g (Const Bool))))
forall {k1} (g :: (k1 -> *) -> *) (f :: k1 -> *).
Distributive g =>
g (Compose ((->) (g f)) f)
Rank2.getters g ((rl s ~> rl s) ~> Const (g (rl s) -> g (rl s)))
forall {k1} (g :: (k1 -> *) -> *) (f :: k1 -> *).
Logistic g =>
g ((f ~> f) ~> Const (g f -> g f))
Rank2.setters g (Const Bool)
candidates g (Fixed p g s)
g
where candidates :: g (Const Bool)
optimize :: forall a. (Compose ((->) (g cb)) cb a)
-> (Rank2.Arrow (f Rank2.~> f) (Const (g f -> g f)) a)
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
optimize :: forall a.
Compose ((->) (g cb)) cb a
-> Arrow (f ~> f) (Const (g f -> g f)) a
-> Const Bool a
-> Fixed p g s a
-> Fixed p g s a
optimize Compose ((->) (g cb)) cb a
getter Arrow (f ~> f) (Const (g f -> g f)) a
setter (Const Bool
True) p :: Fixed p g s a
p@Parser{choices :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> ChoiceTree (Fixed p g s a)
choices= ChoiceTree (Fixed p g s a)
cs} =
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
forall a.
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
optimizeChoice (Compose ((->) (g cb)) cb a -> g cb -> cb a
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose Compose ((->) (g cb)) cb a
getter) (Const (g f -> g f) a -> g f -> g f
forall {k} a (b :: k). Const a b -> a
getConst (Const (g f -> g f) a -> g f -> g f)
-> (f a -> Const (g f -> g f) a) -> f a -> g f -> g f
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Arrow (f ~> f) (Const (g f -> g f)) a
-> (~>) f f a -> Const (g f -> g f) a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
Arrow p q a -> p a -> q a
Rank2.apply Arrow (f ~> f) (Const (g f -> g f)) a
setter ((~>) f f a -> Const (g f -> g f) a)
-> (f a -> (~>) f f a) -> f a -> Const (g f -> g f) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (f a -> f a) -> (~>) f f a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((f a -> f a) -> (~>) f f a)
-> (f a -> f a -> f a) -> f a -> (~>) f f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> f a -> f a
forall a b. a -> b -> a
const) Fixed p g s a
p ChoiceTree (Fixed p g s a)
cs
optimize Compose ((->) (g cb)) cb a
_ Arrow (f ~> f) (Const (g f -> g f)) a
_ Const Bool a
_ Fixed p g s a
p = Fixed p g s a
p
optimizeChoice :: (g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
splitSymmetric :: (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
isLeftRecursive :: (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
leftRecursiveParser :: (g cb -> cb a) -> Fixed p g s a -> Bool
optimizeChoice :: forall a.
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
optimizeChoice g cb -> cb a
_ f a -> g f -> g f
_ Fixed p g s a
fallback Leaf{} = Fixed p g s a
fallback
optimizeChoice g cb -> cb a
get f a -> g f -> g f
set Fixed p g s a
fallback (LeftBiasedChoice ChoiceTree (Fixed p g s a)
p ChoiceTree (Fixed p g s a)
q)
| (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
q = Fixed p g s a
fallback
| Bool -> Bool
not ((g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
p) = Fixed p g s a
fallback
| LeftBiasedChoice ChoiceTree (Fixed p g s a)
p1 ChoiceTree (Fixed p g s a)
p2 <- ChoiceTree (Fixed p g s a)
p, Bool -> Bool
not ((g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
p2)
= (g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
forall a.
(g cb -> cb a)
-> (f a -> g f -> g f)
-> Fixed p g s a
-> ChoiceTree (Fixed p g s a)
-> Fixed p g s a
optimizeChoice g cb -> cb a
get f a -> g f -> g f
set Fixed p g s a
fallback (ChoiceTree (Fixed p g s a) -> Fixed p g s a)
-> ChoiceTree (Fixed p g s a) -> Fixed p g s a
forall a b. (a -> b) -> a -> b
$ ChoiceTree (Fixed p g s a)
-> ChoiceTree (Fixed p g s a) -> ChoiceTree (Fixed p g s a)
forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
LeftBiasedChoice ChoiceTree (Fixed p g s a)
p1 (ChoiceTree (Fixed p g s a)
-> ChoiceTree (Fixed p g s a) -> ChoiceTree (Fixed p g s a)
forall a. ChoiceTree a -> ChoiceTree a -> ChoiceTree a
LeftBiasedChoice ChoiceTree (Fixed p g s a)
p2 ChoiceTree (Fixed p g s a)
q)
| Bool
otherwise = (f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (Fixed p g s), f ~ GrammarFunctor (Fixed p g s),
GrammarConstraint (Fixed p g s) g) =>
(f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chainLongestRecursive f a -> g f -> g f
set (ChoiceTree (Fixed p g s a) -> Fixed p g s a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
q) (ChoiceTree (Fixed p g s a) -> Fixed p g s a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
p)
optimizeChoice g cb -> cb a
get f a -> g f -> g f
set Fixed p g s a
fallback c :: ChoiceTree (Fixed p g s a)
c@SymmetricChoice{}
| [Fixed p g s a] -> Bool
forall m. MonoidNull m => m -> Bool
null [Fixed p g s a]
base = Fixed p g s a
fallback
| [Fixed p g s a] -> Bool
forall m. MonoidNull m => m -> Bool
null [Fixed p g s a]
recursives = Fixed p g s a
fallback
| Bool
otherwise = (f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall (m :: * -> *) (g :: (* -> *) -> *) (f :: * -> *) a.
(GrammarParsing m, g ~ ParserGrammar m, f ~ GrammarFunctor m,
GrammarConstraint m g) =>
(f a -> g f -> g f) -> m a -> m a -> m a
forall (g :: (* -> *) -> *) (f :: * -> *) a.
(g ~ ParserGrammar (Fixed p g s), f ~ GrammarFunctor (Fixed p g s),
GrammarConstraint (Fixed p g s) g) =>
(f a -> g f -> g f)
-> Fixed p g s a -> Fixed p g s a -> Fixed p g s a
chainRecursive f a -> g f -> g f
set ((Fixed p g s a -> Fixed p g s a -> Fixed p g s a)
-> [Fixed p g s a] -> Fixed p g s a
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) [Fixed p g s a]
base) ((Fixed p g s a -> Fixed p g s a -> Fixed p g s a)
-> [Fixed p g s a] -> Fixed p g s a
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall a. Fixed p g s a -> Fixed p g s a -> Fixed p g s a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) [Fixed p g s a]
recursives)
where ([Fixed p g s a]
base, [Fixed p g s a]
recursives) = (g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
c
splitSymmetric :: forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get (SymmetricChoice ChoiceTree (Fixed p g s a)
p ChoiceTree (Fixed p g s a)
q) = (g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
p ([Fixed p g s a], [Fixed p g s a])
-> ([Fixed p g s a], [Fixed p g s a])
-> ([Fixed p g s a], [Fixed p g s a])
forall a. Semigroup a => a -> a -> a
<> (g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
forall a.
(g cb -> cb a)
-> ChoiceTree (Fixed p g s a) -> ([Fixed p g s a], [Fixed p g s a])
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
q
splitSymmetric g cb -> cb a
get ChoiceTree (Fixed p g s a)
c
| (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get ChoiceTree (Fixed p g s a)
c = ([], [ChoiceTree (Fixed p g s a) -> Fixed p g s a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
c])
| Bool
otherwise = ([ChoiceTree (Fixed p g s a) -> Fixed p g s a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices ChoiceTree (Fixed p g s a)
c], [])
isLeftRecursive :: forall a. (g cb -> cb a) -> ChoiceTree (Fixed p g s a) -> Bool
isLeftRecursive g cb -> cb a
get = (g cb -> cb a) -> Fixed p g s a -> Bool
forall a. (g cb -> cb a) -> Fixed p g s a -> Bool
leftRecursiveParser g cb -> cb a
get (Fixed p g s a -> Bool)
-> (ChoiceTree (Fixed p g s a) -> Fixed p g s a)
-> ChoiceTree (Fixed p g s a)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChoiceTree (Fixed p g s a) -> Fixed p g s a
forall (p :: * -> *) a.
(Alternative p, DeterministicParsing p) =>
ChoiceTree (p a) -> p a
collapseChoices
leftRecursiveParser :: forall a. (g cb -> cb a) -> Fixed p g s a -> Bool
leftRecursiveParser g cb -> cb a
get Parser{cyclicDescendants :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= g (Const (ParserFlags g)) -> ParserFlags g
cds} =
Any -> Bool
getAny (Any -> Bool) -> Any -> Bool
forall a b. (a -> b) -> a -> b
$ (forall a. Const Bool a -> Any) -> g (Const Bool) -> Any
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any (Bool -> Any) -> (Const Bool a -> Bool) -> Const Bool a -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const Bool) -> Any) -> g (Const Bool) -> Any
forall a b. (a -> b) -> a -> b
$ (forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
intersection (Const (g (Const Bool)) a -> g (Const Bool)
forall {k} a (b :: k). Const a b -> a
getConst (Const (g (Const Bool)) a -> g (Const Bool))
-> Const (g (Const Bool)) a -> g (Const Bool)
forall a b. (a -> b) -> a -> b
$ g cb -> cb a
get g cb
g (Const (g (Const Bool)))
forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits) (g cb -> g (Const Bool)
deps g cb
g (Const (g (Const Bool)))
forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits)
where deps :: g cb -> g (Const Bool)
deps :: g cb -> g (Const Bool)
deps = Dependencies g -> g (Const Bool)
forall (g :: (* -> *) -> *).
Distributive g =>
Dependencies g -> g (Const Bool)
getDependencies (Dependencies g -> g (Const Bool))
-> (g cb -> Dependencies g) -> g cb -> g (Const Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserFlags g -> Dependencies g
forall (g :: (* -> *) -> *). ParserFlags g -> Dependencies g
dependsOn (ParserFlags g -> Dependencies g)
-> (g cb -> ParserFlags g) -> g cb -> Dependencies g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const (ParserFlags g)) -> ParserFlags g
cds
(g (Const (ParserFlags g)) -> ParserFlags g)
-> (g cb -> g (Const (ParserFlags g))) -> g cb -> ParserFlags g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. cb a -> Const (ParserFlags g) a)
-> g cb -> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (ParserFlags g -> Const (ParserFlags g) a
forall {k} a (b :: k). a -> Const a b
Const (ParserFlags g -> Const (ParserFlags g) a)
-> (cb a -> ParserFlags g) -> cb a -> Const (ParserFlags g) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
False (Dependencies g -> ParserFlags g)
-> (cb a -> Dependencies g) -> cb a -> ParserFlags g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> Dependencies g)
-> (cb a -> g (Const Bool)) -> cb a -> Dependencies g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. cb a -> g (Const Bool)
Const (g (Const Bool)) a -> g (Const Bool)
forall {k} a (b :: k). Const a b -> a
getConst)
leftRecursiveParser g cb -> cb a
_ Fixed p g s a
_ = Bool
False
candidates :: g (Const Bool)
candidates = (forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
intersection (g (Fixed p g s) -> g (Const Bool)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g) =>
g (Fixed p g s) -> g (Const Bool)
cyclicDependencies g (Fixed p g s)
g) (Const Bool a -> Const Bool a
forall x. Const Bool x -> Const Bool x
complement (forall x. Const Bool x -> Const Bool x)
-> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Fixed p g s) -> g (Const Bool)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g) =>
g (Fixed p g s) -> g (Const Bool)
cyclicDependencies g (Fixed p g s)
g')
g' :: g (Fixed p g s)
g' = (forall a.
Const (g (Const Bool)) a -> Fixed p g s a -> Fixed p g s a)
-> g (Const (g (Const Bool))) -> g (Fixed p g s) -> g (Fixed p g s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (g (Const Bool)) a -> Fixed p g s a -> Fixed p g s a
forall a.
Const (g (Const Bool)) a -> Fixed p g s a -> Fixed p g s a
forall {g :: (* -> *) -> *} {b}
{p :: ((* -> *) -> *) -> * -> * -> *} {s} {a}.
Apply g =>
Const (g (Const Bool)) b -> Fixed p g s a -> Fixed p g s a
noDirectLeftRecursion g (Const (g (Const Bool)))
forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits g (Fixed p g s)
g
noDirectLeftRecursion :: Const (g (Const Bool)) b -> Fixed p g s a -> Fixed p g s a
noDirectLeftRecursion (Const g (Const Bool)
bit) p :: Fixed p g s a
p@Parser{cyclicDescendants :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants= g (Const (ParserFlags g)) -> ParserFlags g
cd} = Fixed p g s a
p{cyclicDescendants= excludeSelf . cd}
where excludeSelf :: ParserFlags g -> ParserFlags g
excludeSelf (ParserFlags Bool
n Dependencies g
DynamicDependencies) = Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n Dependencies g
forall (g :: (* -> *) -> *). Dependencies g
DynamicDependencies
excludeSelf (ParserFlags Bool
n (StaticDependencies g (Const Bool)
deps)) =
Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n (Dependencies g -> ParserFlags g)
-> Dependencies g -> ParserFlags g
forall a b. (a -> b) -> a -> b
$ g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> Dependencies g)
-> g (Const Bool) -> Dependencies g
forall a b. (a -> b) -> a -> b
$ (forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
intersection (Const Bool a -> Const Bool a
forall x. Const Bool x -> Const Bool x
complement (forall x. Const Bool x -> Const Bool x)
-> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const Bool)
bit) g (Const Bool)
deps
noDirectLeftRecursion Const (g (Const Bool)) b
_ Fixed p g s a
p = Fixed p g s a
p
separated :: forall p g s. (Alternative (p g s), Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g,
AmbiguousAlternative (GrammarFunctor (p g s))) =>
g (Fixed p g s) -> g (SeparatedParser p g s)
separated :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g,
AmbiguousAlternative (GrammarFunctor (p g s))) =>
g (Fixed p g s) -> g (SeparatedParser p g s)
separated g (Fixed p g s)
g = (forall a.
Const Bool a
-> Const Bool a
-> Const (Dependencies g) a
-> Fixed p g s a
-> SeparatedParser p g s a)
-> g (Const Bool)
-> g (Const Bool)
-> g (Const (Dependencies g))
-> g (Fixed p g s)
-> g (SeparatedParser p g s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *) (s :: k -> *) (t :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a -> s a -> t a)
-> g p -> g q -> g r -> g s -> g t
Rank2.liftA4 Const Bool a
-> Const Bool a
-> Const (Dependencies g) a
-> Fixed p g s a
-> SeparatedParser p g s a
forall a.
Const Bool a
-> Const Bool a
-> Const (Dependencies g) a
-> Fixed p g s a
-> SeparatedParser p g s a
reseparate g (Const Bool)
circulars g (Const Bool)
cycleFollowers g (Const (Dependencies g))
descendants g (Fixed p g s)
g
where descendants :: g (Const (Dependencies g))
cycleFollowers, circulars :: g (Const Bool)
appendResults :: forall a. Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
leftRecursiveDeps :: forall a. Const Bool a -> Const (Dependencies g) a -> Const (g (Const Bool)) a
reseparate :: forall a. Const Bool a -> Const Bool a -> Const (Dependencies g) a -> Fixed p g s a
-> SeparatedParser p g s a
reseparate :: forall a.
Const Bool a
-> Const Bool a
-> Const (Dependencies g) a
-> Fixed p g s a
-> SeparatedParser p g s a
reseparate (Const Bool
circular) (Const Bool
follower) (Const d :: Dependencies g
d@(StaticDependencies g (Const Bool)
deps)) Fixed p g s a
p
| Bool
circular Bool -> Bool -> Bool
|| Bool
leader Bool -> Bool -> Bool
&& Bool
follower =
p g s a
-> p g s a
-> ResultAppend p g s a
-> Dependencies g
-> SeparatedParser p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a
-> p g s a
-> ResultAppend p g s a
-> Dependencies g
-> SeparatedParser p g s a
CycleParser (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p) ((GrammarFunctor (p g s) a
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a)
-> ResultAppend p g s a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a)
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a)
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a)
-> (GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a)
-> GrammarFunctor (p g s) a
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
forall a.
Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
appendResults (Fixed p g s a -> Maybe (AmbiguityWitness a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
p))) Dependencies g
d
| Bool
follower = p g s a -> SeparatedParser p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> SeparatedParser p g s a
BackParser (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
| Bool
otherwise = p g s a -> SeparatedParser p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a -> SeparatedParser p g s a
FrontParser (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
complete Fixed p g s a
p)
where leader :: Bool
leader = Any -> Bool
getAny ((forall a. Const Bool a -> Any) -> g (Const Bool) -> Any
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any (Bool -> Any) -> (Const Bool a -> Bool) -> Const Bool a -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const Bool) -> Any) -> g (Const Bool) -> Any
forall a b. (a -> b) -> a -> b
$ (forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
intersection g (Const Bool)
circulars g (Const Bool)
deps)
reseparate Const Bool a
_ Const Bool a
_ (Const d :: Dependencies g
d@Dependencies g
DynamicDependencies) Fixed p g s a
p =
p g s a
-> p g s a
-> ResultAppend p g s a
-> Dependencies g
-> SeparatedParser p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
p g s a
-> p g s a
-> ResultAppend p g s a
-> Dependencies g
-> SeparatedParser p g s a
CycleParser (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
indirect Fixed p g s a
p) (Fixed p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> p g s a
direct Fixed p g s a
p) ((GrammarFunctor (p g s) a
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a)
-> ResultAppend p g s a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a)
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a)
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a)
-> (GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a)
-> GrammarFunctor (p g s) a
-> Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
forall a.
Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
appendResults (Fixed p g s a -> Maybe (AmbiguityWitness a)
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> Maybe (AmbiguityWitness a)
isAmbiguous Fixed p g s a
p))) Dependencies g
d
appendResults :: forall a.
Maybe (AmbiguityWitness a)
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
appendResults (Just (AmbiguityWitness a :~: Ambiguous b
Refl)) = GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
GrammarFunctor (p g s) (Ambiguous b)
-> GrammarFunctor (p g s) (Ambiguous b)
-> GrammarFunctor (p g s) (Ambiguous b)
forall a.
GrammarFunctor (p g s) (Ambiguous a)
-> GrammarFunctor (p g s) (Ambiguous a)
-> GrammarFunctor (p g s) (Ambiguous a)
forall (f :: * -> *) a.
AmbiguousAlternative f =>
f (Ambiguous a) -> f (Ambiguous a) -> f (Ambiguous a)
ambiguousOr
appendResults Maybe (AmbiguityWitness a)
Nothing = GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
forall a.
GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
descendants :: g (Const (Dependencies g))
descendants = g (Fixed p g s) -> g (Const (Dependencies g))
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Traversable g) =>
g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants g (Fixed p g s)
g
circulars :: g (Const Bool)
circulars = (forall a.
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a)
-> g (Const (g (Const Bool)))
-> g (Const (Dependencies g))
-> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
forall a.
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
forall (g :: (* -> *) -> *) a.
(Apply g, Foldable g) =>
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
leftRecursive g (Const (g (Const Bool)))
forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits g (Const (Dependencies g))
descendants
cycleFollowers :: g (Const Bool)
cycleFollowers = Union g -> g (Const Bool)
forall (g :: (* -> *) -> *). Union g -> g (Const Bool)
getUnion ((forall a. Const (g (Const Bool)) a -> Union g)
-> g (Const (g (Const Bool))) -> Union g
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (g (Const Bool) -> Union g
forall (g :: (* -> *) -> *). g (Const Bool) -> Union g
Union (g (Const Bool) -> Union g)
-> (Const (g (Const Bool)) a -> g (Const Bool))
-> Const (g (Const Bool)) a
-> Union g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const (g (Const Bool)) a -> g (Const Bool)
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const (g (Const Bool))) -> Union g)
-> g (Const (g (Const Bool))) -> Union g
forall a b. (a -> b) -> a -> b
$
(forall a.
Const Bool a
-> Const (Dependencies g) a -> Const (g (Const Bool)) a)
-> g (Const Bool)
-> g (Const (Dependencies g))
-> g (Const (g (Const Bool)))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a
-> Const (Dependencies g) a -> Const (g (Const Bool)) a
forall a.
Const Bool a
-> Const (Dependencies g) a -> Const (g (Const Bool)) a
leftRecursiveDeps g (Const Bool)
circulars g (Const (Dependencies g))
descendants)
leftRecursiveDeps :: forall a.
Const Bool a
-> Const (Dependencies g) a -> Const (g (Const Bool)) a
leftRecursiveDeps (Const Bool
True) (Const (StaticDependencies g (Const Bool)
deps)) = g (Const Bool) -> Const (g (Const Bool)) a
forall {k} a (b :: k). a -> Const a b
Const g (Const Bool)
deps
leftRecursiveDeps (Const Bool
False) (Const (StaticDependencies g (Const Bool)
deps)) =
g (Const Bool) -> Const (g (Const Bool)) a
forall {k} a (b :: k). a -> Const a b
Const ((forall x. Const Bool x -> Const Bool x)
-> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (Const Bool a -> Const Bool a -> Const Bool a
forall a b. a -> b -> a
const (Const Bool a -> Const Bool a -> Const Bool a)
-> Const Bool a -> Const Bool a -> Const Bool a
forall a b. (a -> b) -> a -> b
$ Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
False) g (Const Bool)
deps)
leftRecursiveDeps Const Bool a
_ (Const Dependencies g
DynamicDependencies) = g (Const Bool) -> Const (g (Const Bool)) a
forall {k} a (b :: k). a -> Const a b
Const ((forall a. Fixed p g s a -> Const Bool a)
-> g (Fixed p g s) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (Const Bool a -> Fixed p g s a -> Const Bool a
forall a b. a -> b -> a
const (Const Bool a -> Fixed p g s a -> Const Bool a)
-> Const Bool a -> Fixed p g s a -> Const Bool a
forall a b. (a -> b) -> a -> b
$ Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
True) g (Fixed p g s)
g)
{-# INLINABLE separated #-}
getDependencies :: Rank2.Distributive g => Dependencies g -> g (Const Bool)
getDependencies :: forall (g :: (* -> *) -> *).
Distributive g =>
Dependencies g -> g (Const Bool)
getDependencies (StaticDependencies g (Const Bool)
deps) = g (Const Bool)
deps
getDependencies Dependencies g
DynamicDependencies = (forall a. Maybe (Any a) -> Const Bool a)
-> Maybe (g Any) -> g (Const Bool)
forall {k1} (g :: (k1 -> *) -> *) (m :: * -> *) (p :: k1 -> *)
(q :: k1 -> *).
(Distributive g, Functor m) =>
(forall (a :: k1). m (p a) -> q a) -> m (g p) -> g q
forall (m :: * -> *) (p :: * -> *) (q :: * -> *).
Functor m =>
(forall a. m (p a) -> q a) -> m (g p) -> g q
Rank2.cotraverse (Const Bool a -> Maybe (Any a) -> Const Bool a
forall a b. a -> b -> a
const (Const Bool a -> Maybe (Any a) -> Const Bool a)
-> Const Bool a -> Maybe (Any a) -> Const Bool a
forall a b. (a -> b) -> a -> b
$ Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
True) Maybe (g Any)
forall a. Maybe a
Nothing
cyclicDependencies :: (Alternative (p g s), Rank2.Apply g, Rank2.Distributive g, Rank2.Traversable g)
=> g (Fixed p g s) -> g (Const Bool)
cyclicDependencies :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Distributive g, Traversable g) =>
g (Fixed p g s) -> g (Const Bool)
cyclicDependencies = (forall a.
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a)
-> g (Const (g (Const Bool)))
-> g (Const (Dependencies g))
-> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
forall a.
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
forall (g :: (* -> *) -> *) a.
(Apply g, Foldable g) =>
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
leftRecursive g (Const (g (Const Bool)))
forall (g :: (* -> *) -> *).
(Distributive g, Traversable g) =>
g (Const (g (Const Bool)))
bits (g (Const (Dependencies g)) -> g (Const Bool))
-> (g (Fixed p g s) -> g (Const (Dependencies g)))
-> g (Fixed p g s)
-> g (Const Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Fixed p g s) -> g (Const (Dependencies g))
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Traversable g) =>
g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants
leftRecursive :: forall g a. (Rank2.Apply g, Rank2.Foldable g)
=> Const (g (Const Bool)) a -> Const (Dependencies g) a -> Const Bool a
leftRecursive :: forall (g :: (* -> *) -> *) a.
(Apply g, Foldable g) =>
Const (g (Const Bool)) a
-> Const (Dependencies g) a -> Const Bool a
leftRecursive (Const g (Const Bool)
bit) (Const (StaticDependencies g (Const Bool)
deps)) =
Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const (Any -> Bool
getAny (Any -> Bool) -> Any -> Bool
forall a b. (a -> b) -> a -> b
$ (forall a. Const Bool a -> Any) -> g (Const Bool) -> Any
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any (Bool -> Any) -> (Const Bool a -> Bool) -> Const Bool a -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const Bool) -> Any) -> g (Const Bool) -> Any
forall a b. (a -> b) -> a -> b
$ (forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
intersection g (Const Bool)
bit g (Const Bool)
deps)
leftRecursive Const (g (Const Bool)) a
_ (Const Dependencies g
DynamicDependencies) = Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
True
transitiveDescendants :: (Alternative (p g s), Rank2.Apply g, Rank2.Traversable g)
=> g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
s.
(Alternative (p g s), Apply g, Traversable g) =>
g (Fixed p g s) -> g (Const (Dependencies g))
transitiveDescendants =
(forall a. Const (ParserFlags g) a -> Const (Dependencies g) a)
-> g (Const (ParserFlags g)) -> g (Const (Dependencies g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (Dependencies g -> Const (Dependencies g) a
forall {k} a (b :: k). a -> Const a b
Const (Dependencies g -> Const (Dependencies g) a)
-> (Const (ParserFlags g) a -> Dependencies g)
-> Const (ParserFlags g) a
-> Const (Dependencies g) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserFlags g -> Dependencies g
forall (g :: (* -> *) -> *). ParserFlags g -> Dependencies g
dependsOn (ParserFlags g -> Dependencies g)
-> (Const (ParserFlags g) a -> ParserFlags g)
-> Const (ParserFlags g) a
-> Dependencies g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const (ParserFlags g) a -> ParserFlags g
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const (ParserFlags g)) -> g (Const (Dependencies g)))
-> (g (Fixed p g s) -> g (Const (ParserFlags g)))
-> g (Fixed p g s)
-> g (Const (Dependencies g))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
fixDescendants (g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g)))
-> (g (Fixed p g s)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g)))
-> g (Fixed p g s)
-> g (Const (ParserFlags g))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a.
Fixed p g s a
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a)
-> g (Fixed p g s)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap ((g (Const (ParserFlags g)) -> ParserFlags g)
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a
forall {k} a (b :: k). a -> Const a b
Const ((g (Const (ParserFlags g)) -> ParserFlags g)
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a)
-> (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g)
-> Fixed p g s a
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g
cyclicDescendants (Fixed p g s a -> g (Const (ParserFlags g)) -> ParserFlags g)
-> (Fixed p g s a -> Fixed p g s a)
-> Fixed p g s a
-> g (Const (ParserFlags g))
-> ParserFlags g
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed p g s a -> Fixed p g s a
forall (g :: (* -> *) -> *) (p :: ((* -> *) -> *) -> * -> * -> *) s
a.
(Apply g, Alternative (p g s)) =>
Fixed p g s a -> Fixed p g s a
general)
fixDescendants :: forall g. (Rank2.Apply g, Rank2.Traversable g)
=> g (Const (g (Const (ParserFlags g)) -> (ParserFlags g))) -> g (Const (ParserFlags g))
fixDescendants :: forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
fixDescendants g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf = g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
initial
where go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd
| All -> Bool
getAll ((forall a. Const Bool a -> All) -> g (Const Bool) -> All
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> All
All (Bool -> All) -> (Const Bool a -> Bool) -> Const Bool a -> All
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const Bool) -> All) -> g (Const Bool) -> All
forall a b. (a -> b) -> a -> b
$ (forall a.
Const (ParserFlags g) a -> Const (ParserFlags g) a -> Const Bool a)
-> g (Const (ParserFlags g))
-> g (Const (ParserFlags g))
-> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (ParserFlags g) a -> Const (ParserFlags g) a -> Const Bool a
forall a.
Const (ParserFlags g) a -> Const (ParserFlags g) a -> Const Bool a
forall {g :: (* -> *) -> *} {b} {b} {b}.
(Foldable g, Apply g) =>
Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree g (Const (ParserFlags g))
cd g (Const (ParserFlags g))
cd') = g (Const (ParserFlags g))
cd
| Bool
otherwise = g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd'
where cd' :: g (Const (ParserFlags g))
cd' = (forall a.
Const (ParserFlags g) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a)
-> g (Const (ParserFlags g))
-> g (Const (ParserFlags g))
-> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (ParserFlags g) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a
forall a.
Const (ParserFlags g) a
-> Const (ParserFlags g) a -> Const (ParserFlags g) a
forall {g :: (* -> *) -> *} {b} {b} {b}.
Apply g =>
Const (ParserFlags g) b
-> Const (ParserFlags g) b -> Const (ParserFlags g) b
flagUnion g (Const (ParserFlags g))
cd ((forall a.
Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const (ParserFlags g) a)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (\(Const g (Const (ParserFlags g)) -> ParserFlags g
f)-> ParserFlags g -> Const (ParserFlags g) a
forall {k} a (b :: k). a -> Const a b
Const (g (Const (ParserFlags g)) -> ParserFlags g
f g (Const (ParserFlags g))
cd)) g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf)
agree :: Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree (Const (ParserFlags Bool
_xn (StaticDependencies g (Const Bool)
xd))) (Const (ParserFlags Bool
_yn (StaticDependencies g (Const Bool)
yd))) =
Bool -> Const Bool b
forall {k} a (b :: k). a -> Const a b
Const (All -> Bool
getAll ((forall a. Const Bool a -> All) -> g (Const Bool) -> All
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> All
All (Bool -> All) -> (Const Bool a -> Bool) -> Const Bool a -> All
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) ((forall a. Const Bool a -> Const Bool a -> Const Bool a)
-> g (Const Bool) -> g (Const Bool) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> Const Bool a -> Const Bool a
forall a. Const Bool a -> Const Bool a -> Const Bool a
forall {a} {b} {b} {b}.
Eq a =>
Const a b -> Const a b -> Const Bool b
agree' g (Const Bool)
xd g (Const Bool)
yd)))
agree (Const (ParserFlags Bool
_xn Dependencies g
DynamicDependencies)) (Const (ParserFlags Bool
_yn Dependencies g
DynamicDependencies)) = Bool -> Const Bool b
forall {k} a (b :: k). a -> Const a b
Const Bool
True
agree Const (ParserFlags g) b
_ Const (ParserFlags g) b
_ = Bool -> Const Bool b
forall {k} a (b :: k). a -> Const a b
Const Bool
False
agree' :: Const a b -> Const a b -> Const Bool b
agree' (Const a
x) (Const a
y) = Bool -> Const Bool b
forall {k} a (b :: k). a -> Const a b
Const (a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
y)
flagUnion :: Const (ParserFlags g) b
-> Const (ParserFlags g) b -> Const (ParserFlags g) b
flagUnion (Const ParserFlags{dependsOn :: forall (g :: (* -> *) -> *). ParserFlags g -> Dependencies g
dependsOn= Dependencies g
old}) (Const (ParserFlags Bool
n Dependencies g
new)) =
ParserFlags g -> Const (ParserFlags g) b
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n (Dependencies g -> ParserFlags g)
-> Dependencies g -> ParserFlags g
forall a b. (a -> b) -> a -> b
$ Dependencies g -> Dependencies g -> Dependencies g
forall (g :: (* -> *) -> *).
Apply g =>
Dependencies g -> Dependencies g -> Dependencies g
depUnion Dependencies g
old Dependencies g
new)
initial :: g (Const (ParserFlags g))
initial = (forall a.
Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const Bool a -> Const (ParserFlags g) a)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
-> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 (\Const (g (Const (ParserFlags g)) -> ParserFlags g) a
_ (Const Bool
n)-> ParserFlags g -> Const (ParserFlags g) a
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
n Dependencies g
deps)) g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf g (Const Bool)
nullabilities
deps :: Dependencies g
deps = g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (Const Bool a
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const Bool a
forall a b. a -> b -> a
const (Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
False) (forall {a}.
Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const Bool a)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf)
nullabilities :: g (Const Bool)
nullabilities = g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
fixNullabilities g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf
{-# INLINABLE fixDescendants #-}
fixNullabilities :: forall g. (Rank2.Apply g, Rank2.Traversable g)
=> g (Const (g (Const (ParserFlags g)) -> (ParserFlags g))) -> g (Const Bool)
fixNullabilities :: forall (g :: (* -> *) -> *).
(Apply g, Traversable g) =>
g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
fixNullabilities g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf = Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Const Bool a)
-> (Const (ParserFlags g) a -> Bool)
-> Const (ParserFlags g) a
-> Const Bool a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserFlags g -> Bool
forall (g :: (* -> *) -> *). ParserFlags g -> Bool
nullable (ParserFlags g -> Bool)
-> (Const (ParserFlags g) a -> ParserFlags g)
-> Const (ParserFlags g) a
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const (ParserFlags g) a -> ParserFlags g
forall {k} a (b :: k). Const a b -> a
getConst (forall {a}. Const (ParserFlags g) a -> Const Bool a)
-> g (Const (ParserFlags g)) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
initial
where go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go :: g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd
| All -> Bool
getAll ((forall a. Const Bool a -> All) -> g (Const Bool) -> All
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> All
All (Bool -> All) -> (Const Bool a -> Bool) -> Const Bool a -> All
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const Bool) -> All) -> g (Const Bool) -> All
forall a b. (a -> b) -> a -> b
$ (forall a.
Const (ParserFlags g) a -> Const (ParserFlags g) a -> Const Bool a)
-> g (Const (ParserFlags g))
-> g (Const (ParserFlags g))
-> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const (ParserFlags g) a -> Const (ParserFlags g) a -> Const Bool a
forall a.
Const (ParserFlags g) a -> Const (ParserFlags g) a -> Const Bool a
forall {g :: (* -> *) -> *} {b} {g :: (* -> *) -> *} {b} {b}.
Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree g (Const (ParserFlags g))
cd g (Const (ParserFlags g))
cd') = g (Const (ParserFlags g))
cd
| Bool
otherwise = g (Const (ParserFlags g)) -> g (Const (ParserFlags g))
go g (Const (ParserFlags g))
cd'
where cd' :: g (Const (ParserFlags g))
cd' = (forall a.
Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const (ParserFlags g) a)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (\(Const g (Const (ParserFlags g)) -> ParserFlags g
f)-> ParserFlags g -> Const (ParserFlags g) a
forall {k} a (b :: k). a -> Const a b
Const (g (Const (ParserFlags g)) -> ParserFlags g
f g (Const (ParserFlags g))
cd)) g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf
agree :: Const (ParserFlags g) b -> Const (ParserFlags g) b -> Const Bool b
agree (Const ParserFlags g
flags1) (Const ParserFlags g
flags2) = Bool -> Const Bool b
forall {k} a (b :: k). a -> Const a b
Const (ParserFlags g -> Bool
forall (g :: (* -> *) -> *). ParserFlags g -> Bool
nullable ParserFlags g
flags1 Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== ParserFlags g -> Bool
forall (g :: (* -> *) -> *). ParserFlags g -> Bool
nullable ParserFlags g
flags2)
initial :: g (Const (ParserFlags g))
initial = Const (ParserFlags g) a
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const (ParserFlags g) a
forall a b. a -> b -> a
const (ParserFlags g -> Const (ParserFlags g) a
forall {k} a (b :: k). a -> Const a b
Const (Bool -> Dependencies g -> ParserFlags g
forall (g :: (* -> *) -> *).
Bool -> Dependencies g -> ParserFlags g
ParserFlags Bool
True (g (Const Bool) -> Dependencies g
forall (g :: (* -> *) -> *). g (Const Bool) -> Dependencies g
StaticDependencies (g (Const Bool) -> Dependencies g)
-> g (Const Bool) -> Dependencies g
forall a b. (a -> b) -> a -> b
$ Const Bool a
-> Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const Bool a
forall a b. a -> b -> a
const (Bool -> Const Bool a
forall {k} a (b :: k). a -> Const a b
Const Bool
False) (forall {a}.
Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const Bool a)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf))) (forall a.
Const (g (Const (ParserFlags g)) -> ParserFlags g) a
-> Const (ParserFlags g) a)
-> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
-> g (Const (ParserFlags g))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (Const (g (Const (ParserFlags g)) -> ParserFlags g))
gf
{-# INLINABLE fixNullabilities #-}
parseSeparated :: forall p g rl s. (Rank2.Apply g, Rank2.Foldable g, Eq s, FactorialMonoid s, LeftReductive s,
TailsParsing (p g s), GrammarConstraint (p g s) g,
GrammarFunctor (p g s) ~ rl s, FallibleResults rl,
s ~ ParserInput (p g s)) =>
g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
parseSeparated :: forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *)
(rl :: * -> * -> *) s.
(Apply g, Foldable g, Eq s, FactorialMonoid s, LeftReductive s,
TailsParsing (p g s), GrammarConstraint (p g s) g,
GrammarFunctor (p g s) ~ rl s, FallibleResults rl,
s ~ ParserInput (p g s)) =>
g (SeparatedParser p g s) -> s -> [(s, g (GrammarFunctor (p g s)))]
parseSeparated g (SeparatedParser p g s)
parsers s
input = (s -> [(s, g (rl s))] -> [(s, g (rl s))])
-> [(s, g (rl s))] -> [s] -> [(s, g (rl s))]
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr s -> [(s, g (rl s))] -> [(s, g (rl s))]
parseTail [] (s -> [s]
forall m. FactorialMonoid m => m -> [m]
Factorial.tails s
input)
where parseTail :: s -> [(s, g (rl s))] -> [(s, g (rl s))]
parseTail s
s [(s, g (rl s))]
parsedTail = [(s, g (rl s))]
parsed
where parsed :: [(s, g (rl s))]
parsed = (s
s,g (rl s)
d'')(s, g (rl s)) -> [(s, g (rl s))] -> [(s, g (rl s))]
forall a. a -> [a] -> [a]
:[(s, g (rl s))]
parsedTail
d :: g (rl s)
d = (forall a. p g s a -> rl s a) -> g (p g s) -> g (rl s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap ((([(s, g (rl s))] -> rl s a) -> [(s, g (rl s))] -> rl s a
forall a b. (a -> b) -> a -> b
$ (s
s,g (rl s)
d)(s, g (rl s)) -> [(s, g (rl s))] -> [(s, g (rl s))]
forall a. a -> [a] -> [a]
:[(s, g (rl s))]
parsedTail) (([(s, g (rl s))] -> rl s a) -> rl s a)
-> (p g s a -> [(s, g (rl s))] -> rl s a) -> p g s a -> rl s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p g s a -> [(s, g (rl s))] -> rl s a
p g s a
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) a
forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
forall (g :: (* -> *) -> *) r.
GrammarConstraint (p g s) g =>
p g s r
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) r
parseTails) g (p g s)
directs
d' :: g (GrammarFunctor (p g s))
d' = s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
fixRecursive s
s [(s, g (rl s))]
[(s, g (GrammarFunctor (p g s)))]
parsedTail g (rl s)
g (GrammarFunctor (p g s))
d
d'' :: g (rl s)
d'' = (forall a. SeparatedParser p g s a -> rl s a -> rl s a)
-> g (SeparatedParser p g s) -> g (rl s) -> g (rl s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 SeparatedParser p g s a -> rl s a -> rl s a
SeparatedParser p g s a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
forall a. SeparatedParser p g s a -> rl s a -> rl s a
forall a.
SeparatedParser p g s a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
f g (SeparatedParser p g s)
parsers g (rl s)
g (GrammarFunctor (p g s))
d'
f :: forall a. SeparatedParser p g s a -> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
f :: forall a.
SeparatedParser p g s a
-> GrammarFunctor (p g s) a -> GrammarFunctor (p g s) a
f (FrontParser p g s a
p) GrammarFunctor (p g s) a
_ = p g s a
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) a
forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
forall (g :: (* -> *) -> *) r.
GrammarConstraint (p g s) g =>
p g s r
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) r
parseTails p g s a
p ((s
s,g (rl s)
d'')(s, g (rl s)) -> [(s, g (rl s))] -> [(s, g (rl s))]
forall a. a -> [a] -> [a]
:[(s, g (rl s))]
parsedTail)
f SeparatedParser p g s a
_ GrammarFunctor (p g s) a
result = GrammarFunctor (p g s) a
result
fixRecursive :: s -> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
whileAnyContinues :: (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
recurseTotal :: s -> g (GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s))
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseMarginal :: s -> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
maybeDependencies :: g (Const (Maybe (Dependencies g)))
maybeDependency :: SeparatedParser p g s r -> Const (Maybe (Dependencies g)) r
appends :: g (ResultAppend p g s)
parserAppend :: SeparatedParser p g s r -> ResultAppend p g s r
directs :: g (p g s)
directs = (forall a. SeparatedParser p g s a -> p g s a)
-> g (SeparatedParser p g s) -> g (p g s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap SeparatedParser p g s a -> p g s a
forall a. SeparatedParser p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
backParser g (SeparatedParser p g s)
parsers
indirects :: g (p g s)
indirects = (forall a. SeparatedParser p g s a -> p g s a)
-> g (SeparatedParser p g s) -> g (p g s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap (\SeparatedParser p g s a
p-> case SeparatedParser p g s a
p of {CycleParser{}-> SeparatedParser p g s a -> p g s a
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> p g s a
cycleParser SeparatedParser p g s a
p; SeparatedParser p g s a
_ -> p g s a
forall a. p g s a
forall (f :: * -> *) a. Alternative f => f a
empty}) g (SeparatedParser p g s)
parsers
appends :: g (ResultAppend p g s)
appends = (forall a. SeparatedParser p g s a -> (~>) (rl s) (rl s ~> rl s) a)
-> g (SeparatedParser p g s) -> g (rl s ~> (rl s ~> rl s))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap SeparatedParser p g s a -> Arrow (rl s) (rl s ~> rl s) a
SeparatedParser p g s a -> ResultAppend p g s a
forall a. SeparatedParser p g s a -> (~>) (rl s) (rl s ~> rl s) a
forall r. SeparatedParser p g s r -> ResultAppend p g s r
parserAppend g (SeparatedParser p g s)
parsers
parserAppend :: forall r. SeparatedParser p g s r -> ResultAppend p g s r
parserAppend p :: SeparatedParser p g s r
p@CycleParser{} = SeparatedParser p g s r
-> Arrow
(GrammarFunctor (p g s))
(Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)))
r
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> ResultAppend p g s a
appendResultsArrow SeparatedParser p g s r
p
parserAppend SeparatedParser p g s r
_ = (rl s r -> Arrow (rl s) (rl s) r) -> Arrow (rl s) (rl s ~> rl s) r
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((rl s r -> rl s r) -> Arrow (rl s) (rl s) r
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
(p a -> q a) -> Arrow p q a
Rank2.Arrow ((rl s r -> rl s r) -> Arrow (rl s) (rl s) r)
-> (rl s r -> rl s r -> rl s r) -> rl s r -> Arrow (rl s) (rl s) r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. rl s r -> rl s r -> rl s r
forall a b. a -> b -> a
const)
maybeDependencies :: g (Const (Maybe (Dependencies g)))
maybeDependencies = (forall a.
SeparatedParser p g s a -> Const (Maybe (Dependencies g)) a)
-> g (SeparatedParser p g s) -> g (Const (Maybe (Dependencies g)))
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
Rank2.fmap SeparatedParser p g s a -> Const (Maybe (Dependencies g)) a
forall a.
SeparatedParser p g s a -> Const (Maybe (Dependencies g)) a
maybeDependency g (SeparatedParser p g s)
parsers
maybeDependency :: forall a.
SeparatedParser p g s a -> Const (Maybe (Dependencies g)) a
maybeDependency p :: SeparatedParser p g s r
p@CycleParser{} = Maybe (Dependencies g) -> Const (Maybe (Dependencies g)) r
forall {k} a (b :: k). a -> Const a b
Const (Dependencies g -> Maybe (Dependencies g)
forall a. a -> Maybe a
Just (Dependencies g -> Maybe (Dependencies g))
-> Dependencies g -> Maybe (Dependencies g)
forall a b. (a -> b) -> a -> b
$ SeparatedParser p g s r -> Dependencies g
forall (p :: ((* -> *) -> *) -> * -> * -> *) (g :: (* -> *) -> *) s
a.
SeparatedParser p g s a -> Dependencies g
dependencies SeparatedParser p g s r
p)
maybeDependency SeparatedParser p g s r
_ = Maybe (Dependencies g) -> Const (Maybe (Dependencies g)) r
forall {k} a (b :: k). a -> Const a b
Const Maybe (Dependencies g)
forall a. Maybe a
Nothing
fixRecursive :: s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
fixRecursive s
s [(s, g (GrammarFunctor (p g s)))]
parsedTail g (GrammarFunctor (p g s))
initial =
(g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
whileAnyContinues (s
-> g (Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)))
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseTotal s
s (g (rl s ~> (rl s ~> rl s))
g (ResultAppend p g s)
appends g (rl s ~> (rl s ~> rl s)) -> g (rl s) -> g (rl s ~> rl s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Apply g =>
g (p ~> q) -> g p -> g q
forall (p :: * -> *) (q :: * -> *). g (p ~> q) -> g p -> g q
Rank2.<*> g (rl s)
g (GrammarFunctor (p g s))
initial) [(s, g (GrammarFunctor (p g s)))]
parsedTail)
(s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseMarginal s
s [(s, g (GrammarFunctor (p g s)))]
parsedTail)
g (GrammarFunctor (p g s))
initial g (GrammarFunctor (p g s))
initial
whileAnyContinues :: (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
whileAnyContinues g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
ft g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
fm g (GrammarFunctor (p g s))
total g (GrammarFunctor (p g s))
marginal =
(forall a.
Const (Maybe (Dependencies g)) a -> rl s a -> rl s a -> rl s a)
-> g (Const (Maybe (Dependencies g)))
-> g (rl s)
-> g (rl s)
-> g (rl s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *) (s :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a -> s a)
-> g p -> g q -> g r -> g s
forall (p :: * -> *) (q :: * -> *) (r :: * -> *) (s :: * -> *).
(forall a. p a -> q a -> r a -> s a) -> g p -> g q -> g r -> g s
Rank2.liftA3 Const (Maybe (Dependencies g)) a -> rl s a -> rl s a -> rl s a
Const (Maybe (Dependencies g)) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
-> GrammarFunctor (p g s) a
forall a.
Const (Maybe (Dependencies g)) a -> rl s a -> rl s a -> rl s a
forall x.
Const (Maybe (Dependencies g)) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
choiceWhile g (Const (Maybe (Dependencies g)))
maybeDependencies g (rl s)
g (GrammarFunctor (p g s))
total ((g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s)))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
whileAnyContinues g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
ft g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
fm (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
ft g (GrammarFunctor (p g s))
total) (g (GrammarFunctor (p g s)) -> g (GrammarFunctor (p g s))
fm g (GrammarFunctor (p g s))
marginal))
where choiceWhile :: Const (Maybe (Dependencies g)) x
-> GrammarFunctor (p g s) x -> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
choiceWhile :: forall x.
Const (Maybe (Dependencies g)) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
-> GrammarFunctor (p g s) x
choiceWhile (Const Maybe (Dependencies g)
Nothing) GrammarFunctor (p g s) x
t GrammarFunctor (p g s) x
_ = GrammarFunctor (p g s) x
t
choiceWhile (Const (Just (StaticDependencies g (Const Bool)
deps))) GrammarFunctor (p g s) x
t GrammarFunctor (p g s) x
t'
| Any -> Bool
getAny ((forall a. Const Bool a -> Any) -> g (Const Bool) -> Any
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any (Bool -> Any) -> (Const Bool a -> Bool) -> Const Bool a -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) ((forall a. Const Bool a -> rl s a -> Const Bool a)
-> g (Const Bool) -> g (rl s) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Const Bool a -> rl s a -> Const Bool a
Const Bool a -> GrammarFunctor (p g s) a -> Const Bool a
forall a. Const Bool a -> rl s a -> Const Bool a
forall x. Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combine g (Const Bool)
deps g (rl s)
g (GrammarFunctor (p g s))
marginal)) = GrammarFunctor (p g s) x
t'
| rl s x -> Bool
forall s a. rl s a -> Bool
forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess rl s x
GrammarFunctor (p g s) x
t = GrammarFunctor (p g s) x
t
| Bool
otherwise =
ParseFailure Pos s -> rl s x
forall s a. ParseFailure Pos s -> rl s a
forall (f :: * -> * -> *) s a.
FallibleResults f =>
ParseFailure Pos s -> f s a
failWith (rl s x -> ParseFailure Pos s
forall s a. rl s a -> ParseFailure Pos s
forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure Pos s
failureOf (rl s x -> ParseFailure Pos s) -> rl s x -> ParseFailure Pos s
forall a b. (a -> b) -> a -> b
$
if Any -> Bool
getAny ((forall a. Const Bool a -> Any) -> g (Const Bool) -> Any
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any (Bool -> Any) -> (Const Bool a -> Bool) -> Const Bool a -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Const Bool a -> Bool
forall {k} a (b :: k). Const a b -> a
getConst) (g (Const Bool) -> Any) -> g (Const Bool) -> Any
forall a b. (a -> b) -> a -> b
$
(forall a. Const Bool a -> rl s a -> Const Bool a)
-> g (Const Bool) -> g (rl s) -> g (Const Bool)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 (ParseFailure Pos s
-> Const Bool a -> GrammarFunctor (p g s) a -> Const Bool a
forall x.
ParseFailure Pos s
-> Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combineFailures (ParseFailure Pos s
-> Const Bool a -> GrammarFunctor (p g s) a -> Const Bool a)
-> ParseFailure Pos s
-> Const Bool a
-> GrammarFunctor (p g s) a
-> Const Bool a
forall a b. (a -> b) -> a -> b
$ rl s x -> ParseFailure Pos s
forall s a. rl s a -> ParseFailure Pos s
forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure Pos s
failureOf rl s x
GrammarFunctor (p g s) x
t) g (Const Bool)
deps g (rl s)
g (GrammarFunctor (p g s))
marginal)
then rl s x
GrammarFunctor (p g s) x
t' else rl s x
GrammarFunctor (p g s) x
t)
where combine :: Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combineFailures :: ParseFailure Pos s -> Const Bool x -> GrammarFunctor (p g s) x
-> Const Bool x
combine :: forall x. Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combine (Const Bool
False) GrammarFunctor (p g s) x
_ = Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const Bool
False
combine (Const Bool
True) GrammarFunctor (p g s) x
results = Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const (rl s x -> Bool
forall s a. rl s a -> Bool
forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess rl s x
GrammarFunctor (p g s) x
results)
combineFailures :: forall x.
ParseFailure Pos s
-> Const Bool x -> GrammarFunctor (p g s) x -> Const Bool x
combineFailures ParseFailure Pos s
_ (Const Bool
False) GrammarFunctor (p g s) x
_ = Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const Bool
False
combineFailures (ParseFailure Pos
pos (FailureDescription [String]
expected [s]
_inputs) [String]
errors) (Const Bool
True) GrammarFunctor (p g s) x
rl =
Bool -> Const Bool x
forall {k} a (b :: k). a -> Const a b
Const (Pos
pos Pos -> Pos -> Bool
forall a. Ord a => a -> a -> Bool
< Pos
pos'
Bool -> Bool -> Bool
|| Pos
pos Pos -> Pos -> Bool
forall a. Eq a => a -> a -> Bool
== Pos
pos' Bool -> Bool -> Bool
&& ((String -> Bool) -> [String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String]
expected) [String]
expected'
Bool -> Bool -> Bool
|| (String -> Bool) -> [String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String]
expected) [String]
expected')
Bool -> Bool -> Bool
|| (String -> Bool) -> [String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [String]
errors) [String]
errors')
where ParseFailure Pos
pos' (FailureDescription [String]
expected' [s]
_inputs) [String]
errors' = rl s x -> ParseFailure Pos s
forall s a. rl s a -> ParseFailure Pos s
forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure Pos s
failureOf rl s x
GrammarFunctor (p g s) x
rl
choiceWhile (Const (Just Dependencies g
DynamicDependencies)) GrammarFunctor (p g s) x
t GrammarFunctor (p g s) x
t'
| Any -> Bool
getAny ((forall a. rl s a -> Any) -> g (rl s) -> Any
forall m (p :: * -> *).
Monoid m =>
(forall a. p a -> m) -> g p -> m
forall {k} (g :: (k -> *) -> *) m (p :: k -> *).
(Foldable g, Monoid m) =>
(forall (a :: k). p a -> m) -> g p -> m
Rank2.foldMap (Bool -> Any
Any (Bool -> Any) -> (rl s a -> Bool) -> rl s a -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. rl s a -> Bool
forall s a. rl s a -> Bool
forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess) g (rl s)
g (GrammarFunctor (p g s))
marginal) = GrammarFunctor (p g s) x
t'
| rl s x -> Bool
forall s a. rl s a -> Bool
forall (f :: * -> * -> *) s a. FallibleResults f => f s a -> Bool
hasSuccess rl s x
GrammarFunctor (p g s) x
t = GrammarFunctor (p g s) x
t
| ParseFailure Pos
_ (FailureDescription [] []) [] <- rl s x -> ParseFailure Pos s
forall s a. rl s a -> ParseFailure Pos s
forall (f :: * -> * -> *) s a.
FallibleResults f =>
f s a -> ParseFailure Pos s
failureOf rl s x
GrammarFunctor (p g s) x
t = GrammarFunctor (p g s) x
t'
| Bool
otherwise = GrammarFunctor (p g s) x
t
recurseTotal :: s
-> g (Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)))
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseTotal s
s g (Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)))
initialAppends [(s, g (GrammarFunctor (p g s)))]
parsedTail g (GrammarFunctor (p g s))
total = (forall a. (~>) (rl s) (rl s) a -> p g s a -> rl s a)
-> g (rl s ~> rl s) -> g (p g s) -> g (rl s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *)
(r :: k -> *).
Apply g =>
(forall (a :: k). p a -> q a -> r a) -> g p -> g q -> g r
forall (p :: * -> *) (q :: * -> *) (r :: * -> *).
(forall a. p a -> q a -> r a) -> g p -> g q -> g r
Rank2.liftA2 Arrow (rl s) (rl s) a -> p g s a -> rl s a
(~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
-> p g s a -> GrammarFunctor (p g s) a
forall a. (~>) (rl s) (rl s) a -> p g s a -> rl s a
forall a.
(~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
-> p g s a -> GrammarFunctor (p g s) a
reparse g (rl s ~> rl s)
g (Arrow (GrammarFunctor (p g s)) (GrammarFunctor (p g s)))
initialAppends g (p g s)
indirects
where reparse :: (GrammarFunctor (p g s) Rank2.~> GrammarFunctor (p g s)) a -> p g s a
-> GrammarFunctor (p g s) a
reparse :: forall a.
(~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
-> p g s a -> GrammarFunctor (p g s) a
reparse (~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
append p g s a
p = Arrow (rl s) (rl s) a -> rl s a -> rl s a
forall {k} (p :: k -> *) (q :: k -> *) (a :: k).
Arrow p q a -> p a -> q a
Rank2.apply Arrow (rl s) (rl s) a
(~>) (GrammarFunctor (p g s)) (GrammarFunctor (p g s)) a
append (p g s a
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) a
forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
forall (g :: (* -> *) -> *) r.
GrammarConstraint (p g s) g =>
p g s r
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) r
parseTails p g s a
p ([(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) a)
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) a
forall a b. (a -> b) -> a -> b
$ (s
s, g (rl s)
g (GrammarFunctor (p g s))
total) (s, g (rl s)) -> [(s, g (rl s))] -> [(s, g (rl s))]
forall a. a -> [a] -> [a]
: [(s, g (rl s))]
[(s, g (GrammarFunctor (p g s)))]
parsedTail)
recurseMarginal :: s
-> [(s, g (GrammarFunctor (p g s)))]
-> g (GrammarFunctor (p g s))
-> g (GrammarFunctor (p g s))
recurseMarginal s
s [(s, g (GrammarFunctor (p g s)))]
parsedTail g (GrammarFunctor (p g s))
marginal =
(p g s a -> [(s, g (rl s))] -> rl s a)
-> [(s, g (rl s))] -> p g s a -> rl s a
forall a b c. (a -> b -> c) -> b -> a -> c
flip p g s a -> [(s, g (rl s))] -> rl s a
p g s a
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) a
forall (m :: * -> *) (g :: (* -> *) -> *) r.
(TailsParsing m, GrammarConstraint m g) =>
m r
-> [(ParserInput m, g (GrammarFunctor m))] -> GrammarFunctor m r
forall (g :: (* -> *) -> *) r.
GrammarConstraint (p g s) g =>
p g s r
-> [(ParserInput (p g s), g (GrammarFunctor (p g s)))]
-> GrammarFunctor (p g s) r
parseTails ((s
s, g (rl s)
g (GrammarFunctor (p g s))
marginal) (s, g (rl s)) -> [(s, g (rl s))] -> [(s, g (rl s))]
forall a. a -> [a] -> [a]
: [(s, g (rl s))]
[(s, g (GrammarFunctor (p g s)))]
parsedTail) (forall a. p g s a -> rl s a) -> g (p g s) -> g (rl s)
forall {k} (g :: (k -> *) -> *) (p :: k -> *) (q :: k -> *).
Functor g =>
(forall (a :: k). p a -> q a) -> g p -> g q
forall (p :: * -> *) (q :: * -> *).
(forall a. p a -> q a) -> g p -> g q
Rank2.<$> g (p g s)
indirects
{-# NOINLINE parseSeparated #-}