module Parsley.Internal.Core.Primitives (
Parser,
Reg,
module Parsley.Internal.Core.Primitives
) where
import Prelude hiding (pure)
import Parsley.Internal.Core.CombinatorAST (Combinator(..), ScopeRegister(..), Reg(..), Parser(..))
import Parsley.Internal.Core.Defunc (Defunc(BLACK))
import Parsley.Internal.Common.Indexed (Fix(In), (:+:)(..))
import Parsley.Internal.Common.Utils (WQ)
class ParserOps rep where
pure :: rep a -> Parser a
satisfy :: rep (Char -> Bool)
-> Parser Char
conditional :: [(rep (a -> Bool), Parser b)]
-> Parser a
-> Parser b
-> Parser b
instance ParserOps WQ where
pure :: WQ a -> Parser a
pure = Defunc a -> Parser a
forall (rep :: Type -> Type) a. ParserOps rep => rep a -> Parser a
pure (Defunc a -> Parser a) -> (WQ a -> Defunc a) -> WQ a -> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WQ a -> Defunc a
forall a. WQ a -> Defunc a
BLACK
satisfy :: WQ (Char -> Bool) -> Parser Char
satisfy = Defunc (Char -> Bool) -> Parser Char
forall (rep :: Type -> Type).
ParserOps rep =>
rep (Char -> Bool) -> Parser Char
satisfy (Defunc (Char -> Bool) -> Parser Char)
-> (WQ (Char -> Bool) -> Defunc (Char -> Bool))
-> WQ (Char -> Bool)
-> Parser Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WQ (Char -> Bool) -> Defunc (Char -> Bool)
forall a. WQ a -> Defunc a
BLACK
conditional :: [(WQ (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b
conditional = [(Defunc (a -> Bool), Parser b)]
-> Parser a -> Parser b -> Parser b
forall (rep :: Type -> Type) a b.
ParserOps rep =>
[(rep (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b
conditional ([(Defunc (a -> Bool), Parser b)]
-> Parser a -> Parser b -> Parser b)
-> ([(WQ (a -> Bool), Parser b)]
-> [(Defunc (a -> Bool), Parser b)])
-> [(WQ (a -> Bool), Parser b)]
-> Parser a
-> Parser b
-> Parser b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((WQ (a -> Bool), Parser b) -> (Defunc (a -> Bool), Parser b))
-> [(WQ (a -> Bool), Parser b)] -> [(Defunc (a -> Bool), Parser b)]
forall a b. (a -> b) -> [a] -> [b]
map (\(WQ (a -> Bool)
f, Parser b
t) -> (WQ (a -> Bool) -> Defunc (a -> Bool)
forall a. WQ a -> Defunc a
BLACK WQ (a -> Bool)
f, Parser b
t))
instance {-# INCOHERENT #-} x ~ Defunc => ParserOps x where
pure :: x a -> Parser a
pure = x a -> Parser a
forall a. Defunc a -> Parser a
_pure
satisfy :: x (Char -> Bool) -> Parser Char
satisfy = x (Char -> Bool) -> Parser Char
Defunc (Char -> Bool) -> Parser Char
_satisfy
conditional :: [(x (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b
conditional = [(x (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b
forall a b.
[(Defunc (a -> Bool), Parser b)]
-> Parser a -> Parser b -> Parser b
_conditional
{-# INLINE _pure #-}
_pure :: Defunc a -> Parser a
_pure :: Defunc a -> Parser a
_pure = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser (Fix (Combinator :+: ScopeRegister) a -> Parser a)
-> (Defunc a -> Fix (Combinator :+: ScopeRegister) a)
-> Defunc a
-> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a)
-> (Defunc a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a)
-> Defunc a
-> Fix (Combinator :+: ScopeRegister) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a)
-> (Defunc a -> Combinator (Fix (Combinator :+: ScopeRegister)) a)
-> Defunc a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Defunc a -> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall a (k :: Type -> Type). Defunc a -> Combinator k a
Pure
infixl 4 <*>
(<*>) :: Parser (a -> b) -> Parser a -> Parser b
Parser Fix (Combinator :+: ScopeRegister) (a -> b)
p <*> :: Parser (a -> b) -> Parser a -> Parser b
<*> Parser Fix (Combinator :+: ScopeRegister) a
q = Fix (Combinator :+: ScopeRegister) b -> Parser b
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
-> Fix (Combinator :+: ScopeRegister) b
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) b
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) (a -> b)
p Fix (Combinator :+: ScopeRegister) (a -> b)
-> Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) b
forall (k :: Type -> Type) a b. k (a -> b) -> k a -> Combinator k b
:<*>: Fix (Combinator :+: ScopeRegister) a
q)))
infixl 4 <*
(<*) :: Parser a -> Parser b -> Parser a
Parser Fix (Combinator :+: ScopeRegister) a
p <* :: Parser a -> Parser b -> Parser a
<* Parser Fix (Combinator :+: ScopeRegister) b
q = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) a
p Fix (Combinator :+: ScopeRegister) a
-> Fix (Combinator :+: ScopeRegister) b
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a b. k a -> k b -> Combinator k a
:<*: Fix (Combinator :+: ScopeRegister) b
q)))
infixl 4 *>
(*>) :: Parser a -> Parser b -> Parser b
Parser Fix (Combinator :+: ScopeRegister) a
p *> :: Parser a -> Parser b -> Parser b
*> Parser Fix (Combinator :+: ScopeRegister) b
q = Fix (Combinator :+: ScopeRegister) b -> Parser b
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
-> Fix (Combinator :+: ScopeRegister) b
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) b
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) a
p Fix (Combinator :+: ScopeRegister) a
-> Fix (Combinator :+: ScopeRegister) b
-> Combinator (Fix (Combinator :+: ScopeRegister)) b
forall (k :: Type -> Type) a b. k a -> k b -> Combinator k b
:*>: Fix (Combinator :+: ScopeRegister) b
q)))
empty :: Parser a
empty :: Parser a
empty = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. Combinator k a
Empty))
infixr 3 <|>
(<|>) :: Parser a -> Parser a -> Parser a
Parser Fix (Combinator :+: ScopeRegister) a
p <|> :: Parser a -> Parser a -> Parser a
<|> Parser Fix (Combinator :+: ScopeRegister) a
q = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) a
p Fix (Combinator :+: ScopeRegister) a
-> Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. k a -> k a -> Combinator k a
:<|>: Fix (Combinator :+: ScopeRegister) a
q)))
{-# INLINE _satisfy #-}
_satisfy :: Defunc (Char -> Bool) -> Parser Char
_satisfy :: Defunc (Char -> Bool) -> Parser Char
_satisfy = Fix (Combinator :+: ScopeRegister) Char -> Parser Char
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser (Fix (Combinator :+: ScopeRegister) Char -> Parser Char)
-> (Defunc (Char -> Bool)
-> Fix (Combinator :+: ScopeRegister) Char)
-> Defunc (Char -> Bool)
-> Parser Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) Char
-> Fix (Combinator :+: ScopeRegister) Char
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) Char
-> Fix (Combinator :+: ScopeRegister) Char)
-> (Defunc (Char -> Bool)
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) Char)
-> Defunc (Char -> Bool)
-> Fix (Combinator :+: ScopeRegister) Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Combinator (Fix (Combinator :+: ScopeRegister)) Char
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) Char
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Combinator (Fix (Combinator :+: ScopeRegister)) Char
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) Char)
-> (Defunc (Char -> Bool)
-> Combinator (Fix (Combinator :+: ScopeRegister)) Char)
-> Defunc (Char -> Bool)
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Defunc (Char -> Bool)
-> Combinator (Fix (Combinator :+: ScopeRegister)) Char
forall (k :: Type -> Type).
Defunc (Char -> Bool) -> Combinator k Char
Satisfy
lookAhead :: Parser a -> Parser a
lookAhead :: Parser a -> Parser a
lookAhead = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser (Fix (Combinator :+: ScopeRegister) a -> Parser a)
-> (Parser a -> Fix (Combinator :+: ScopeRegister) a)
-> Parser a
-> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a)
-> (Parser a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a)
-> Parser a
-> Fix (Combinator :+: ScopeRegister) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a)
-> (Parser a -> Combinator (Fix (Combinator :+: ScopeRegister)) a)
-> Parser a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. k a -> Combinator k a
LookAhead (Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a)
-> (Parser a -> Fix (Combinator :+: ScopeRegister) a)
-> Parser a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser a -> Fix (Combinator :+: ScopeRegister) a
forall a. Parser a -> Fix (Combinator :+: ScopeRegister) a
unParser
notFollowedBy :: Parser a -> Parser ()
notFollowedBy :: Parser a -> Parser ()
notFollowedBy = Fix (Combinator :+: ScopeRegister) () -> Parser ()
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser (Fix (Combinator :+: ScopeRegister) () -> Parser ())
-> (Parser a -> Fix (Combinator :+: ScopeRegister) ())
-> Parser a
-> Parser ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ()
-> Fix (Combinator :+: ScopeRegister) ()
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ()
-> Fix (Combinator :+: ScopeRegister) ())
-> (Parser a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ())
-> Parser a
-> Fix (Combinator :+: ScopeRegister) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Combinator (Fix (Combinator :+: ScopeRegister)) ()
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ()
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Combinator (Fix (Combinator :+: ScopeRegister)) ()
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ())
-> (Parser a -> Combinator (Fix (Combinator :+: ScopeRegister)) ())
-> Parser a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) ()
forall (k :: Type -> Type) a. k a -> Combinator k ()
NotFollowedBy (Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) ())
-> (Parser a -> Fix (Combinator :+: ScopeRegister) a)
-> Parser a
-> Combinator (Fix (Combinator :+: ScopeRegister)) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser a -> Fix (Combinator :+: ScopeRegister) a
forall a. Parser a -> Fix (Combinator :+: ScopeRegister) a
unParser
try :: Parser a -> Parser a
try :: Parser a -> Parser a
try = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser (Fix (Combinator :+: ScopeRegister) a -> Parser a)
-> (Parser a -> Fix (Combinator :+: ScopeRegister) a)
-> Parser a
-> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a)
-> (Parser a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a)
-> Parser a
-> Fix (Combinator :+: ScopeRegister) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a)
-> (Parser a -> Combinator (Fix (Combinator :+: ScopeRegister)) a)
-> Parser a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. k a -> Combinator k a
Try (Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a)
-> (Parser a -> Fix (Combinator :+: ScopeRegister) a)
-> Parser a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser a -> Fix (Combinator :+: ScopeRegister) a
forall a. Parser a -> Fix (Combinator :+: ScopeRegister) a
unParser
{-# INLINE _conditional #-}
_conditional :: [(Defunc (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b
_conditional :: [(Defunc (a -> Bool), Parser b)]
-> Parser a -> Parser b -> Parser b
_conditional [(Defunc (a -> Bool), Parser b)]
cs (Parser Fix (Combinator :+: ScopeRegister) a
p) (Parser Fix (Combinator :+: ScopeRegister) b
def) =
let ([Defunc (a -> Bool)]
fs, [Parser b]
qs) = [(Defunc (a -> Bool), Parser b)]
-> ([Defunc (a -> Bool)], [Parser b])
forall a b. [(a, b)] -> ([a], [b])
unzip [(Defunc (a -> Bool), Parser b)]
cs
in Fix (Combinator :+: ScopeRegister) b -> Parser b
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
-> Fix (Combinator :+: ScopeRegister) b
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) b
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) a
-> [Defunc (a -> Bool)]
-> [Fix (Combinator :+: ScopeRegister) b]
-> Fix (Combinator :+: ScopeRegister) b
-> Combinator (Fix (Combinator :+: ScopeRegister)) b
forall (k :: Type -> Type) a b.
k a -> [Defunc (a -> Bool)] -> [k b] -> k b -> Combinator k b
Match Fix (Combinator :+: ScopeRegister) a
p [Defunc (a -> Bool)]
fs ((Parser b -> Fix (Combinator :+: ScopeRegister) b)
-> [Parser b] -> [Fix (Combinator :+: ScopeRegister) b]
forall a b. (a -> b) -> [a] -> [b]
map Parser b -> Fix (Combinator :+: ScopeRegister) b
forall a. Parser a -> Fix (Combinator :+: ScopeRegister) a
unParser [Parser b]
qs) Fix (Combinator :+: ScopeRegister) b
def)))
branch :: Parser (Either a b)
-> Parser (a -> c)
-> Parser (b -> c)
-> Parser c
branch :: Parser (Either a b)
-> Parser (a -> c) -> Parser (b -> c) -> Parser c
branch (Parser Fix (Combinator :+: ScopeRegister) (Either a b)
c) (Parser Fix (Combinator :+: ScopeRegister) (a -> c)
p) (Parser Fix (Combinator :+: ScopeRegister) (b -> c)
q) = Fix (Combinator :+: ScopeRegister) c -> Parser c
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) c
-> Fix (Combinator :+: ScopeRegister) c
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) c
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) c
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) (Either a b)
-> Fix (Combinator :+: ScopeRegister) (a -> c)
-> Fix (Combinator :+: ScopeRegister) (b -> c)
-> Combinator (Fix (Combinator :+: ScopeRegister)) c
forall (k :: Type -> Type) a b c.
k (Either a b) -> k (a -> c) -> k (b -> c) -> Combinator k c
Branch Fix (Combinator :+: ScopeRegister) (Either a b)
c Fix (Combinator :+: ScopeRegister) (a -> c)
p Fix (Combinator :+: ScopeRegister) (b -> c)
q)))
chainPre :: Parser (a -> a) -> Parser a -> Parser a
chainPre :: Parser (a -> a) -> Parser a -> Parser a
chainPre (Parser Fix (Combinator :+: ScopeRegister) (a -> a)
op) (Parser Fix (Combinator :+: ScopeRegister) a
p) = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) (a -> a)
-> Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. k (a -> a) -> k a -> Combinator k a
ChainPre Fix (Combinator :+: ScopeRegister) (a -> a)
op Fix (Combinator :+: ScopeRegister) a
p)))
chainPost :: Parser a -> Parser (a -> a) -> Parser a
chainPost :: Parser a -> Parser (a -> a) -> Parser a
chainPost (Parser Fix (Combinator :+: ScopeRegister) a
p) (Parser Fix (Combinator :+: ScopeRegister) (a -> a)
op) = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (Fix (Combinator :+: ScopeRegister) a
-> Fix (Combinator :+: ScopeRegister) (a -> a)
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. k a -> k (a -> a) -> Combinator k a
ChainPost Fix (Combinator :+: ScopeRegister) a
p Fix (Combinator :+: ScopeRegister) (a -> a)
op)))
newRegister :: Parser a
-> (forall r. Reg r a -> Parser b)
-> Parser b
newRegister :: Parser a -> (forall r. Reg r a -> Parser b) -> Parser b
newRegister (Parser Fix (Combinator :+: ScopeRegister) a
p) forall r. Reg r a -> Parser b
f = Fix (Combinator :+: ScopeRegister) b -> Parser b
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
-> Fix (Combinator :+: ScopeRegister) b
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
forall k k (g :: k -> k -> Type) (k :: k) (a :: k)
(f :: k -> k -> Type).
g k a -> (:+:) f g k a
R (Fix (Combinator :+: ScopeRegister) a
-> (forall r. Reg r a -> Fix (Combinator :+: ScopeRegister) b)
-> ScopeRegister (Fix (Combinator :+: ScopeRegister)) b
forall (k :: Type -> Type) a b.
k a -> (forall r. Reg r a -> k b) -> ScopeRegister k b
ScopeRegister Fix (Combinator :+: ScopeRegister) a
p (Parser b -> Fix (Combinator :+: ScopeRegister) b
forall a. Parser a -> Fix (Combinator :+: ScopeRegister) a
unParser (Parser b -> Fix (Combinator :+: ScopeRegister) b)
-> (Reg r a -> Parser b)
-> Reg r a
-> Fix (Combinator :+: ScopeRegister) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reg r a -> Parser b
forall r. Reg r a -> Parser b
f))))
get :: Reg r a -> Parser a
get :: Reg r a -> Parser a
get (Reg ΣVar a
reg) = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (ΣVar a -> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall a (k :: Type -> Type). ΣVar a -> Combinator k a
GetRegister ΣVar a
reg)))
put :: Reg r a -> Parser a -> Parser ()
put :: Reg r a -> Parser a -> Parser ()
put (Reg ΣVar a
reg) (Parser Fix (Combinator :+: ScopeRegister) a
p) = Fix (Combinator :+: ScopeRegister) () -> Parser ()
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ()
-> Fix (Combinator :+: ScopeRegister) ()
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) ()
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) ()
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (ΣVar a
-> Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) ()
forall a (k :: Type -> Type). ΣVar a -> k a -> Combinator k ()
PutRegister ΣVar a
reg Fix (Combinator :+: ScopeRegister) a
p)))
debug :: String
-> Parser a
-> Parser a
debug :: String -> Parser a -> Parser a
debug String
name (Parser Fix (Combinator :+: ScopeRegister) a
p) = Fix (Combinator :+: ScopeRegister) a -> Parser a
forall a. Fix (Combinator :+: ScopeRegister) a -> Parser a
Parser ((:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
-> Fix (Combinator :+: ScopeRegister) a
forall k (f :: (k -> Type) -> k -> Type) (a :: k).
f (Fix f) a -> Fix f a
In (Combinator (Fix (Combinator :+: ScopeRegister)) a
-> (:+:)
Combinator ScopeRegister (Fix (Combinator :+: ScopeRegister)) a
forall k k (f :: k -> k -> Type) (k :: k) (a :: k)
(g :: k -> k -> Type).
f k a -> (:+:) f g k a
L (String
-> Fix (Combinator :+: ScopeRegister) a
-> Combinator (Fix (Combinator :+: ScopeRegister)) a
forall (k :: Type -> Type) a. String -> k a -> Combinator k a
Debug String
name Fix (Combinator :+: ScopeRegister) a
p)))