{-# LANGUAGE GADTs, UndecidableInstances #-}
module Distribution.Compat.Parsing
(
choice
, option
, optional
, skipOptional
, between
, some
, many
, sepBy
, sepByNonEmpty
, sepEndByNonEmpty
, sepEndBy
, endByNonEmpty
, endBy
, count
, chainl
, chainr
, chainl1
, chainr1
, manyTill
, Parsing(..)
) where
import Prelude ()
import Distribution.Compat.Prelude
import Control.Applicative ((<**>), optional)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State.Lazy as Lazy
import Control.Monad.Trans.State.Strict as Strict
import Control.Monad.Trans.Writer.Lazy as Lazy
import Control.Monad.Trans.Writer.Strict as Strict
import Control.Monad.Trans.RWS.Lazy as Lazy
import Control.Monad.Trans.RWS.Strict as Strict
import Control.Monad.Trans.Reader (ReaderT (..))
import Control.Monad.Trans.Identity (IdentityT (..))
import Data.Foldable (asum)
import qualified Data.List.NonEmpty as NE
import qualified Text.Parsec as Parsec
choice :: Alternative m => [m a] -> m a
choice :: forall (m :: * -> *) a. Alternative m => [m a] -> m a
choice = forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
{-# INLINE choice #-}
option :: Alternative m => a -> m a -> m a
option :: forall (m :: * -> *) a. Alternative m => a -> m a -> m a
option a
x m a
p = m a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
{-# INLINE option #-}
skipOptional :: Alternative m => m a -> m ()
skipOptional :: forall (m :: * -> *) a. Alternative m => m a -> m ()
skipOptional m a
p = (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ m a
p) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
{-# INLINE skipOptional #-}
between :: Applicative m => m bra -> m ket -> m a -> m a
between :: forall (m :: * -> *) bra ket a.
Applicative m =>
m bra -> m ket -> m a -> m a
between m bra
bra m ket
ket m a
p = m bra
bra forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* m ket
ket
{-# INLINE between #-}
sepBy :: Alternative m => m a -> m sep -> m [a]
sepBy :: forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
sepBy m a
p m sep
sep = forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
sepByNonEmpty m a
p m sep
sep forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure []
{-# INLINE sepBy #-}
sepByNonEmpty :: Alternative m => m a -> m sep -> m (NonEmpty a)
sepByNonEmpty :: forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
sepByNonEmpty m a
p m sep
sep = forall a. a -> [a] -> NonEmpty a
(:|) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (m sep
sep forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> m a
p)
{-# INLINE sepByNonEmpty #-}
sepEndByNonEmpty :: Alternative m => m a -> m sep -> m (NonEmpty a)
sepEndByNonEmpty :: forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
sepEndByNonEmpty m a
p m sep
sep = forall a. a -> [a] -> NonEmpty a
(:|) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((m sep
sep forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
sepEndBy m a
p m sep
sep) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure [])
sepEndBy :: Alternative m => m a -> m sep -> m [a]
sepEndBy :: forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
sepEndBy m a
p m sep
sep = forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
sepEndByNonEmpty m a
p m sep
sep forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure []
{-# INLINE sepEndBy #-}
endByNonEmpty :: Alternative m => m a -> m sep -> m (NonEmpty a)
endByNonEmpty :: forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
endByNonEmpty m a
p m sep
sep = forall (f :: * -> *) a. Alternative f => f a -> f (NonEmpty a)
NE.some1 (m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* m sep
sep)
{-# INLINE endByNonEmpty #-}
endBy :: Alternative m => m a -> m sep -> m [a]
endBy :: forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
endBy m a
p m sep
sep = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* m sep
sep)
{-# INLINE endBy #-}
count :: Applicative m => Int -> m a -> m [a]
count :: forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
count Int
n m a
p | Int
n forall a. Ord a => a -> a -> Bool
<= Int
0 = forall (f :: * -> *) a. Applicative f => a -> f a
pure []
| Bool
otherwise = forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA (forall a. Int -> a -> [a]
replicate Int
n m a
p)
{-# INLINE count #-}
chainr :: Alternative m => m a -> m (a -> a -> a) -> a -> m a
chainr :: forall (m :: * -> *) a.
Alternative m =>
m a -> m (a -> a -> a) -> a -> m a
chainr m a
p m (a -> a -> a)
op a
x = forall (m :: * -> *) a.
Alternative m =>
m a -> m (a -> a -> a) -> m a
chainr1 m a
p m (a -> a -> a)
op forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
{-# INLINE chainr #-}
chainl :: Alternative m => m a -> m (a -> a -> a) -> a -> m a
chainl :: forall (m :: * -> *) a.
Alternative m =>
m a -> m (a -> a -> a) -> a -> m a
chainl m a
p m (a -> a -> a)
op a
x = forall (m :: * -> *) a.
Alternative m =>
m a -> m (a -> a -> a) -> m a
chainl1 m a
p m (a -> a -> a)
op forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
{-# INLINE chainl #-}
chainl1 :: Alternative m => m a -> m (a -> a -> a) -> m a
chainl1 :: forall (m :: * -> *) a.
Alternative m =>
m a -> m (a -> a -> a) -> m a
chainl1 m a
p m (a -> a -> a)
op = m a
scan where
scan :: m a
scan = m a
p forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> m (a -> a)
rst
rst :: m (a -> a)
rst = (\a -> a -> a
f a
y a -> a
g a
x -> a -> a
g (a -> a -> a
f a
x a
y)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a -> a -> a)
op forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (a -> a)
rst forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. a -> a
id
{-# INLINE chainl1 #-}
chainr1 :: Alternative m => m a -> m (a -> a -> a) -> m a
chainr1 :: forall (m :: * -> *) a.
Alternative m =>
m a -> m (a -> a -> a) -> m a
chainr1 m a
p m (a -> a -> a)
op = m a
scan where
scan :: m a
scan = m a
p forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> m (a -> a)
rst
rst :: m (a -> a)
rst = (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a -> a -> a)
op forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
scan) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. a -> a
id
{-# INLINE chainr1 #-}
manyTill :: Alternative m => m a -> m end -> m [a]
manyTill :: forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
manyTill m a
p m end
end = m [a]
go where go :: m [a]
go = ([] forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ m end
end) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m [a]
go)
{-# INLINE manyTill #-}
infixr 0 <?>
class Alternative m => Parsing m where
try :: m a -> m a
(<?>) :: m a -> String -> m a
skipMany :: m a -> m ()
skipMany m a
p = () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (f :: * -> *) a. Alternative f => f a -> f [a]
many m a
p
{-# INLINE skipMany #-}
skipSome :: m a -> m ()
skipSome m a
p = m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. Parsing m => m a -> m ()
skipMany m a
p
{-# INLINE skipSome #-}
unexpected :: String -> m a
eof :: m ()
notFollowedBy :: Show a => m a -> m ()
instance (Parsing m, MonadPlus m) => Parsing (Lazy.StateT s m) where
try :: forall a. StateT s m a -> StateT s m a
try (Lazy.StateT s -> m (a, s)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, s)
m
{-# INLINE try #-}
Lazy.StateT s -> m (a, s)
m <?> :: forall a. StateT s m a -> String -> StateT s m a
<?> String
l = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> s -> m (a, s)
m s
s forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l
{-# INLINE (<?>) #-}
unexpected :: forall a. String -> StateT s m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: StateT s m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => StateT s m a -> StateT s m ()
notFollowedBy (Lazy.StateT s -> m (a, s)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT
forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> s -> m (a, s)
m s
s) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return ((),s
s)
{-# INLINE notFollowedBy #-}
instance (Parsing m, MonadPlus m) => Parsing (Strict.StateT s m) where
try :: forall a. StateT s m a -> StateT s m a
try (Strict.StateT s -> m (a, s)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, s)
m
{-# INLINE try #-}
Strict.StateT s -> m (a, s)
m <?> :: forall a. StateT s m a -> String -> StateT s m a
<?> String
l = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> s -> m (a, s)
m s
s forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l
{-# INLINE (<?>) #-}
unexpected :: forall a. String -> StateT s m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: StateT s m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => StateT s m a -> StateT s m ()
notFollowedBy (Strict.StateT s -> m (a, s)
m) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT
forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> s -> m (a, s)
m s
s) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return ((),s
s)
{-# INLINE notFollowedBy #-}
instance (Parsing m, MonadPlus m) => Parsing (ReaderT e m) where
try :: forall a. ReaderT e m a -> ReaderT e m a
try (ReaderT e -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> m a
m
{-# INLINE try #-}
ReaderT e -> m a
m <?> :: forall a. ReaderT e m a -> String -> ReaderT e m a
<?> String
l = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT forall a b. (a -> b) -> a -> b
$ \e
e -> e -> m a
m e
e forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l
{-# INLINE (<?>) #-}
skipMany :: forall a. ReaderT e m a -> ReaderT e m ()
skipMany (ReaderT e -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m ()
skipMany forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> m a
m
{-# INLINE skipMany #-}
unexpected :: forall a. String -> ReaderT e m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: ReaderT e m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => ReaderT e m a -> ReaderT e m ()
notFollowedBy (ReaderT e -> m a
m) = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> m a
m
{-# INLINE notFollowedBy #-}
instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Strict.WriterT w m) where
try :: forall a. WriterT w m a -> WriterT w m a
try (Strict.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try m (a, w)
m
{-# INLINE try #-}
Strict.WriterT m (a, w)
m <?> :: forall a. WriterT w m a -> String -> WriterT w m a
<?> String
l = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, w)
m forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l)
{-# INLINE (<?>) #-}
unexpected :: forall a. String -> WriterT w m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: WriterT w m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => WriterT w m a -> WriterT w m ()
notFollowedBy (Strict.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT
forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w)
m) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \()
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (()
x, forall a. Monoid a => a
mempty)
{-# INLINE notFollowedBy #-}
instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Lazy.WriterT w m) where
try :: forall a. WriterT w m a -> WriterT w m a
try (Lazy.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try m (a, w)
m
{-# INLINE try #-}
Lazy.WriterT m (a, w)
m <?> :: forall a. WriterT w m a -> String -> WriterT w m a
<?> String
l = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT (m (a, w)
m forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l)
{-# INLINE (<?>) #-}
unexpected :: forall a. String -> WriterT w m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: WriterT w m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => WriterT w m a -> WriterT w m ()
notFollowedBy (Lazy.WriterT m (a, w)
m) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT
forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (a, w)
m) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \()
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (()
x, forall a. Monoid a => a
mempty)
{-# INLINE notFollowedBy #-}
instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Lazy.RWST r w s m) where
try :: forall a. RWST r w s m a -> RWST r w s m a
try (Lazy.RWST r -> s -> m (a, s, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) a. Parsing m => m a -> m a
try (r -> s -> m (a, s, w)
m r
r s
s)
{-# INLINE try #-}
Lazy.RWST r -> s -> m (a, s, w)
m <?> :: forall a. RWST r w s m a -> String -> RWST r w s m a
<?> String
l = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> r -> s -> m (a, s, w)
m r
r s
s forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l
{-# INLINE (<?>) #-}
unexpected :: forall a. String -> RWST r w s m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: RWST r w s m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => RWST r w s m a -> RWST r w s m ()
notFollowedBy (Lazy.RWST r -> s -> m (a, s, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy ((\(a
a,s
_,w
_) -> a
a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r -> s -> m (a, s, w)
m r
r s
s) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \()
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (()
x, s
s, forall a. Monoid a => a
mempty)
{-# INLINE notFollowedBy #-}
instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Strict.RWST r w s m) where
try :: forall a. RWST r w s m a -> RWST r w s m a
try (Strict.RWST r -> s -> m (a, s, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) a. Parsing m => m a -> m a
try (r -> s -> m (a, s, w)
m r
r s
s)
{-# INLINE try #-}
Strict.RWST r -> s -> m (a, s, w)
m <?> :: forall a. RWST r w s m a -> String -> RWST r w s m a
<?> String
l = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> r -> s -> m (a, s, w)
m r
r s
s forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l
{-# INLINE (<?>) #-}
unexpected :: forall a. String -> RWST r w s m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: RWST r w s m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => RWST r w s m a -> RWST r w s m ()
notFollowedBy (Strict.RWST r -> s -> m (a, s, w)
m) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy ((\(a
a,s
_,w
_) -> a
a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> r -> s -> m (a, s, w)
m r
r s
s) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \()
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (()
x, s
s, forall a. Monoid a => a
mempty)
{-# INLINE notFollowedBy #-}
instance (Parsing m, Monad m) => Parsing (IdentityT m) where
try :: forall a. IdentityT m a -> IdentityT m a
try = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => m a -> m a
try forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT
{-# INLINE try #-}
IdentityT m a
m <?> :: forall a. IdentityT m a -> String -> IdentityT m a
<?> String
l = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a
m forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
l)
{-# INLINE (<?>) #-}
skipMany :: forall a. IdentityT m a -> IdentityT m ()
skipMany = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => m a -> m ()
skipMany forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (a :: k). IdentityT f a -> f a
runIdentityT
{-# INLINE skipMany #-}
unexpected :: forall a. String -> IdentityT m a
unexpected = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. Parsing m => String -> m a
unexpected
{-# INLINE unexpected #-}
eof :: IdentityT m ()
eof = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). Parsing m => m ()
eof
{-# INLINE eof #-}
notFollowedBy :: forall a. Show a => IdentityT m a -> IdentityT m ()
notFollowedBy (IdentityT m a
m) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy m a
m
{-# INLINE notFollowedBy #-}
instance (Parsec.Stream s m t, Show t) => Parsing (Parsec.ParsecT s u m) where
try :: forall a. ParsecT s u m a -> ParsecT s u m a
try = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
Parsec.try
<?> :: forall a. ParsecT s u m a -> String -> ParsecT s u m a
(<?>) = forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
(Parsec.<?>)
skipMany :: forall a. ParsecT s u m a -> ParsecT s u m ()
skipMany = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany
skipSome :: forall a. ParsecT s u m a -> ParsecT s u m ()
skipSome = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
Parsec.skipMany1
unexpected :: forall a. String -> ParsecT s u m a
unexpected = forall s (m :: * -> *) t u a.
Stream s m t =>
String -> ParsecT s u m a
Parsec.unexpected
eof :: ParsecT s u m ()
eof = forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
Parsec.eof
notFollowedBy :: forall a. Show a => ParsecT s u m a -> ParsecT s u m ()
notFollowedBy = forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
Parsec.notFollowedBy