{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fspec-constr -fspec-constr-count=8 #-}
module Distribution.Compat.CharParsing
(
oneOf
, noneOf
, spaces
, space
, newline
, tab
, upper
, lower
, alphaNum
, letter
, digit
, hexDigit
, octDigit
, satisfyRange
, CharParsing(..)
, integral
, signedIntegral
, munch1
, munch
, skipSpaces1
, module Distribution.Compat.Parsing
) where
import Prelude ()
import Distribution.Compat.Prelude
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.Char
import Data.Text (Text, unpack)
import qualified Text.Parsec as Parsec
import Distribution.Compat.Parsing
oneOf :: CharParsing m => [Char] -> m Char
oneOf :: forall (m :: * -> *). CharParsing m => [Char] -> m Char
oneOf [Char]
xs = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy (\Char
c -> Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char]
xs)
{-# INLINE oneOf #-}
noneOf :: CharParsing m => [Char] -> m Char
noneOf :: forall (m :: * -> *). CharParsing m => [Char] -> m Char
noneOf [Char]
xs = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy (\Char
c -> Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Char]
xs)
{-# INLINE noneOf #-}
spaces :: CharParsing m => m ()
spaces :: forall (m :: * -> *). CharParsing m => m ()
spaces = forall (m :: * -> *) a. Parsing m => m a -> m ()
skipMany forall (m :: * -> *). CharParsing m => m Char
space forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"white space"
{-# INLINE spaces #-}
space :: CharParsing m => m Char
space :: forall (m :: * -> *). CharParsing m => m Char
space = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isSpace forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"space"
{-# INLINE space #-}
newline :: CharParsing m => m Char
newline :: forall (m :: * -> *). CharParsing m => m Char
newline = forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'\n' forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"new-line"
{-# INLINE newline #-}
tab :: CharParsing m => m Char
tab :: forall (m :: * -> *). CharParsing m => m Char
tab = forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'\t' forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"tab"
{-# INLINE tab #-}
upper :: CharParsing m => m Char
upper :: forall (m :: * -> *). CharParsing m => m Char
upper = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isUpper forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"uppercase letter"
{-# INLINE upper #-}
lower :: CharParsing m => m Char
lower :: forall (m :: * -> *). CharParsing m => m Char
lower = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isLower forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"lowercase letter"
{-# INLINE lower #-}
alphaNum :: CharParsing m => m Char
alphaNum :: forall (m :: * -> *). CharParsing m => m Char
alphaNum = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isAlphaNum forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"letter or digit"
{-# INLINE alphaNum #-}
letter :: CharParsing m => m Char
letter :: forall (m :: * -> *). CharParsing m => m Char
letter = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isAlpha forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"letter"
{-# INLINE letter #-}
digit :: CharParsing m => m Char
digit :: forall (m :: * -> *). CharParsing m => m Char
digit = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isDigit forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"digit"
{-# INLINE digit #-}
hexDigit :: CharParsing m => m Char
hexDigit :: forall (m :: * -> *). CharParsing m => m Char
hexDigit = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isHexDigit forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"hexadecimal digit"
{-# INLINE hexDigit #-}
octDigit :: CharParsing m => m Char
octDigit :: forall (m :: * -> *). CharParsing m => m Char
octDigit = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy Char -> Bool
isOctDigit forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"octal digit"
{-# INLINE octDigit #-}
satisfyRange :: CharParsing m => Char -> Char -> m Char
satisfyRange :: forall (m :: * -> *). CharParsing m => Char -> Char -> m Char
satisfyRange Char
a Char
z = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy (\Char
c -> Char
c forall a. Ord a => a -> a -> Bool
>= Char
a Bool -> Bool -> Bool
&& Char
c forall a. Ord a => a -> a -> Bool
<= Char
z)
{-# INLINE satisfyRange #-}
class Parsing m => CharParsing m where
satisfy :: (Char -> Bool) -> m Char
char :: Char -> m Char
char Char
c = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy (Char
c forall a. Eq a => a -> a -> Bool
==) forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> forall a. Show a => a -> [Char]
show [Char
c]
{-# INLINE char #-}
notChar :: Char -> m Char
notChar Char
c = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy (Char
c forall a. Eq a => a -> a -> Bool
/=)
{-# INLINE notChar #-}
anyChar :: m Char
anyChar = forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy (forall a b. a -> b -> a
const Bool
True)
{-# INLINE anyChar #-}
string :: String -> m String
string [Char]
s = [Char]
s forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ forall (m :: * -> *). CharParsing m => Char -> m Char
char [Char]
s) forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> forall a. Show a => a -> [Char]
show [Char]
s
{-# INLINE string #-}
text :: Text -> m Text
text Text
t = Text
t forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). CharParsing m => [Char] -> m [Char]
string (Text -> [Char]
unpack Text
t)
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m) => CharParsing (Lazy.StateT s m) where
satisfy :: (Char -> Bool) -> StateT s m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> StateT s m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> StateT s m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: StateT s m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> StateT s m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> StateT s m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m) => CharParsing (Strict.StateT s m) where
satisfy :: (Char -> Bool) -> StateT s m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> StateT s m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> StateT s m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: StateT s m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> StateT s m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> StateT s m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m) => CharParsing (ReaderT e m) where
satisfy :: (Char -> Bool) -> ReaderT e m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> ReaderT e m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> ReaderT e m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: ReaderT e m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> ReaderT e m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> ReaderT e m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Strict.WriterT w m) where
satisfy :: (Char -> Bool) -> WriterT w m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> WriterT w m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> WriterT w m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: WriterT w m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> WriterT w m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> WriterT w m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Lazy.WriterT w m) where
satisfy :: (Char -> Bool) -> WriterT w m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> WriterT w m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> WriterT w m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: WriterT w m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> WriterT w m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> WriterT w m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Lazy.RWST r w s m) where
satisfy :: (Char -> Bool) -> RWST r w s m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> RWST r w s m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> RWST r w s m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: RWST r w s m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> RWST r w s m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> RWST r w s m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Strict.RWST r w s m) where
satisfy :: (Char -> Bool) -> RWST r w s m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> RWST r w s m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> RWST r w s m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: RWST r w s m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> RWST r w s m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> RWST r w s m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance (CharParsing m, MonadPlus m) => CharParsing (IdentityT m) where
satisfy :: (Char -> Bool) -> IdentityT m Char
satisfy = 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 :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE satisfy #-}
char :: Char -> IdentityT m Char
char = 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 :: * -> *). CharParsing m => Char -> m Char
char
{-# INLINE char #-}
notChar :: Char -> IdentityT m Char
notChar = 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 :: * -> *). CharParsing m => Char -> m Char
notChar
{-# INLINE notChar #-}
anyChar :: IdentityT m Char
anyChar = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall (m :: * -> *). CharParsing m => m Char
anyChar
{-# INLINE anyChar #-}
string :: [Char] -> IdentityT m [Char]
string = 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 :: * -> *). CharParsing m => [Char] -> m [Char]
string
{-# INLINE string #-}
text :: Text -> IdentityT m Text
text = 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 :: * -> *). CharParsing m => Text -> m Text
text
{-# INLINE text #-}
instance Parsec.Stream s m Char => CharParsing (Parsec.ParsecT s u m) where
satisfy :: (Char -> Bool) -> ParsecT s u m Char
satisfy = forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
Parsec.satisfy
char :: Char -> ParsecT s u m Char
char = forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
Parsec.char
notChar :: Char -> ParsecT s u m Char
notChar Char
c = forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
Parsec.satisfy (forall a. Eq a => a -> a -> Bool
/= Char
c)
anyChar :: ParsecT s u m Char
anyChar = forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
Parsec.anyChar
string :: [Char] -> ParsecT s u m [Char]
string = forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
Parsec.string
integral :: (CharParsing m, Integral a) => m a
integral :: forall (m :: * -> *) a. (CharParsing m, Integral a) => m a
integral = [a] -> a
toNumber forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Alternative f => f a -> f [a]
some m a
d forall (m :: * -> *) a. Parsing m => m a -> [Char] -> m a
<?> [Char]
"integral"
where
toNumber :: [a] -> a
toNumber = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\a
a a
b -> a
a forall a. Num a => a -> a -> a
* a
10 forall a. Num a => a -> a -> a
+ a
b) a
0
d :: m a
d = forall {a}. Num a => Char -> a
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). CharParsing m => Char -> Char -> m Char
satisfyRange Char
'0' Char
'9'
f :: Char -> a
f Char
'0' = a
0
f Char
'1' = a
1
f Char
'2' = a
2
f Char
'3' = a
3
f Char
'4' = a
4
f Char
'5' = a
5
f Char
'6' = a
6
f Char
'7' = a
7
f Char
'8' = a
8
f Char
'9' = a
9
f Char
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"panic! integral"
{-# INLINE integral #-}
signedIntegral :: (CharParsing m, Integral a) => m a
signedIntegral :: forall (m :: * -> *) a. (CharParsing m, Integral a) => m a
signedIntegral = forall a. Num a => a -> a
negate forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'-' forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *) a. (CharParsing m, Integral a) => m a
integral forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. (CharParsing m, Integral a) => m a
integral
{-# INLINE signedIntegral #-}
munch1 :: CharParsing m => (Char -> Bool) -> m String
munch1 :: forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m [Char]
munch1 = forall (f :: * -> *) a. Alternative f => f a -> f [a]
some forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE munch1 #-}
munch :: CharParsing m => (Char -> Bool) -> m String
munch :: forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m [Char]
munch = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m Char
satisfy
{-# INLINE munch #-}
skipSpaces1 :: CharParsing m => m ()
skipSpaces1 :: forall (m :: * -> *). CharParsing m => m ()
skipSpaces1 = forall (m :: * -> *) a. Parsing m => m a -> m ()
skipSome forall (m :: * -> *). CharParsing m => m Char
space
{-# INLINE skipSpaces1 #-}