-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parallel Parsing Processes -- -- Koen Claessen's PPP, Modified. @package parsek @version 1.0.4.0 module Text.ParserCombinators.Class -- | Parser class class (Monad p, Alternative p) => IsParser p where { type family SymbolOf p; } satisfy :: IsParser p => (SymbolOf p -> Bool) -> p (SymbolOf p) look :: IsParser p => p [SymbolOf p] label :: IsParser p => String -> p a -> p a (<<|>) :: IsParser p => p a -> p a -> p a infixr 3 <<|> -- | Label a parser (>) :: IsParser p => p a -> String -> p a infix 2 > char :: (IsParser p, Eq (SymbolOf p), Show (SymbolOf p)) => SymbolOf p -> p (SymbolOf p) noneOf :: (IsParser p, SymbolOf p ~# Char) => [Char] -> p Char oneOf :: (IsParser p, SymbolOf p ~# Char) => [Char] -> p Char spaces :: (IsParser p, SymbolOf p ~# Char) => p () space :: (IsParser p, SymbolOf p ~# Char) => p Char newline :: (IsParser p, Eq (SymbolOf p), Show (SymbolOf p), SymbolOf p ~# Char) => p Char tab :: (IsParser p, Eq (SymbolOf p), Show (SymbolOf p), SymbolOf p ~# Char) => p Char upper :: (IsParser p, SymbolOf p ~# Char) => p Char lower :: (IsParser p, SymbolOf p ~# Char) => p Char alphaNum :: (IsParser p, SymbolOf p ~# Char) => p Char letter :: (IsParser p, SymbolOf p ~# Char) => p Char digit :: (IsParser p, SymbolOf p ~# Char) => p Char hexDigit :: (IsParser p, SymbolOf p ~# Char) => p Char octDigit :: (IsParser p, SymbolOf p ~# Char) => p Char anySymbol :: IsParser p => p (SymbolOf p) string :: (IsParser p, SymbolOf p ~ Char) => String -> p String choice :: Alternative f => [f a] -> f a option :: Alternative f => a -> f a -> f a between :: Applicative m => m x -> m y -> m a -> m a -- | Greedy repetition: match as many occurences as possible of the -- argument. manyGreedy :: IsParser m => m a -> m [a] skipMany1 :: Alternative f => f a -> f () skipMany :: Alternative f => f a -> f () sepBy :: Alternative f => f a1 -> f a2 -> f [a1] sepBy1 :: Alternative f => f a1 -> f a2 -> f [a1] count :: Applicative m => Int -> m a -> m [a] chainr :: (Alternative f, Monad f) => f a -> f (a -> a -> a) -> a -> f a chainl :: (Alternative f, Monad f) => f a -> f (a -> a -> a) -> a -> f a chainr1 :: (Monad f, Alternative f) => f t -> f (t -> t -> t) -> f t chainl1 :: (Alternative m, Monad m) => m b -> m (b -> b -> b) -> m b munch :: IsParser m => (SymbolOf m -> Bool) -> m [SymbolOf m] munch1 :: IsParser m => (SymbolOf m -> Bool) -> m [SymbolOf m] endOfFile :: IsParser p => p () -- | This module provides the Parsek library developed by Koen -- Claessen in his functional pearl article Parallel Parsing -- Processes, Journal of Functional Programming, 14(6), 741-757, -- Cambridge University Press, 2004: -- -- http://www.cs.chalmers.se/~koen/pubs/entry-jfp04-parser.html module Text.ParserCombinators.Parsek data Parser s a -- | An intersection (nesting) of things currently expected type Expect s = [(String, Maybe s)] type ParseMethod s a r = P s a -> [s] -> ParseResult s r type ParseResult s r = Either (Err s) r mapErrR :: (s -> s') -> ParseResult s r -> ParseResult s' r parseFromFile :: Parser Char a -> ParseMethod Char a r -> FilePath -> IO (ParseResult Char r) parse :: Parser s a -> ParseMethod s a r -> [s] -> ParseResult s r shortestResult :: ParseMethod s a a longestResult :: ParseMethod s a a longestResults :: ParseMethod s a [a] allResults :: ParseMethod s a [a] allResultsStaged :: ParseMethod s a [[a]] completeResults :: ParseMethod s a [a] shortestResultWithLeftover :: ParseMethod s a (a, [s]) longestResultWithLeftover :: ParseMethod s a (a, [s]) longestResultsWithLeftover :: ParseMethod s a ([a], Maybe [s]) allResultsWithLeftover :: ParseMethod s a [(a, [s])] -- | Conditional failure of Alternative computations. Defined by -- --
-- guard True = pure () -- guard False = empty ---- --
-- >>> safeDiv 4 0 -- Nothing -- >>> safeDiv 4 2 -- Just 2 ---- -- A definition of safeDiv using guards, but not guard: -- --
-- safeDiv :: Int -> Int -> Maybe Int -- safeDiv x y | y /= 0 = Just (x `div` y) -- | otherwise = Nothing ---- -- A definition of safeDiv using guard and Monad -- do-notation: -- --
-- safeDiv :: Int -> Int -> Maybe Int -- safeDiv x y = do -- guard (y /= 0) -- return (x `div` y) --guard :: Alternative f => Bool -> f () -- | forM_ is mapM_ with its arguments flipped. For a version -- that doesn't ignore the results see forM. -- -- As of base 4.8.0.0, forM_ is just for_, specialized to -- Monad. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () -- | In many situations, the liftM operations can be replaced by -- uses of ap, which promotes function application. -- --
-- return f `ap` x1 `ap` ... `ap` xn ---- -- is equivalent to -- --
-- liftMn f x1 x2 ... xn --ap :: Monad m => m (a -> b) -> m a -> m b -- | Monads that also support choice and failure. class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) -- | The identity of mplus. It should also satisfy the equations -- --
-- mzero >>= f = mzero -- v >> mzero = mzero ---- -- The default definition is -- --
-- mzero = empty --mzero :: MonadPlus m => m a -- | An associative operation. The default definition is -- --
-- mplus = (<|>) --mplus :: MonadPlus m => m a -> m a -> m a instance GHC.Base.Functor (Text.ParserCombinators.Parsek.Parser s) instance GHC.Base.Monad (Text.ParserCombinators.Parsek.Parser s) instance Control.Monad.Fail.MonadFail (Text.ParserCombinators.Parsek.Parser s) instance GHC.Base.MonadPlus (Text.ParserCombinators.Parsek.Parser s) instance GHC.Base.Applicative (Text.ParserCombinators.Parsek.Parser s) instance GHC.Base.Alternative (Text.ParserCombinators.Parsek.Parser s) instance Text.ParserCombinators.Class.IsParser (Text.ParserCombinators.Parsek.Parser s) module Text.ParserCombinators.Parsek.Position -- | Conditional failure of Alternative computations. Defined by -- --
-- guard True = pure () -- guard False = empty ---- --
-- >>> safeDiv 4 0 -- Nothing -- >>> safeDiv 4 2 -- Just 2 ---- -- A definition of safeDiv using guards, but not guard: -- --
-- safeDiv :: Int -> Int -> Maybe Int -- safeDiv x y | y /= 0 = Just (x `div` y) -- | otherwise = Nothing ---- -- A definition of safeDiv using guard and Monad -- do-notation: -- --
-- safeDiv :: Int -> Int -> Maybe Int -- safeDiv x y = do -- guard (y /= 0) -- return (x `div` y) --guard :: Alternative f => Bool -> f () -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. (<$) :: Functor f => a -> f b -> f a infixl 4 <$ -- | A functor with application, providing operations to -- --
-- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> -- v = v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. (<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. (*>) :: Applicative f => f a -> f b -> f b -- | Sequence actions, discarding the value of the second argument. (<*) :: Applicative f => f a -> f b -> f a infixl 4 <*> infixl 4 *> infixl 4 <* -- | One or none. optional :: Alternative f => f a -> f (Maybe a) newtype WrappedMonad (m :: Type -> Type) a WrapMonad :: m a -> WrappedMonad a [unwrapMonad] :: WrappedMonad a -> m a newtype WrappedArrow (a :: Type -> Type -> Type) b c WrapArrow :: a b c -> WrappedArrow b c [unwrapArrow] :: WrappedArrow b c -> a b c -- | Lists, but with an Applicative functor based on zipping. newtype ZipList a ZipList :: [a] -> ZipList a [getZipList] :: ZipList a -> [a] -- | The Const functor. newtype Const a (b :: k) :: forall k. () => Type -> k -> Type Const :: a -> Const a [getConst] :: Const a -> a -- | forM_ is mapM_ with its arguments flipped. For a version -- that doesn't ignore the results see forM. -- -- As of base 4.8.0.0, forM_ is just for_, specialized to -- Monad. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is -- function application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to -- an Either Int String using -- show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | In many situations, the liftM operations can be replaced by -- uses of ap, which promotes function application. -- --
-- return f `ap` x1 `ap` ... `ap` xn ---- -- is equivalent to -- --
-- liftMn f x1 x2 ... xn --ap :: Monad m => m (a -> b) -> m a -> m b -- | Lift a ternary function to actions. liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d -- | Lift a function to actions. This function may be used as a value for -- fmap in a Functor instance. liftA :: Applicative f => (a -> b) -> f a -> f b -- | A variant of <*> with the arguments reversed. (<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 <**> -- | A monoid on applicative functors. -- -- If defined, some and many should be the least solutions -- of the equations: -- -- class Applicative f => Alternative (f :: Type -> Type) -- | The identity of <|> empty :: Alternative f => f a -- | An associative binary operation (<|>) :: Alternative f => f a -> f a -> f a -- | One or more. some :: Alternative f => f a -> f [a] -- | Zero or more. many :: Alternative f => f a -> f [a] infixl 3 <|> -- | Monads that also support choice and failure. class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) -- | The identity of mplus. It should also satisfy the equations -- --
-- mzero >>= f = mzero -- v >> mzero = mzero ---- -- The default definition is -- --
-- mzero = empty --mzero :: MonadPlus m => m a -- | An associative operation. The default definition is -- --
-- mplus = (<|>) --mplus :: MonadPlus m => m a -> m a -> m a -- | Parser class class (Monad p, Alternative p) => IsParser p where { type family SymbolOf p; } satisfy :: IsParser p => (SymbolOf p -> Bool) -> p (SymbolOf p) look :: IsParser p => p [SymbolOf p] label :: IsParser p => String -> p a -> p a (<<|>) :: IsParser p => p a -> p a -> p a infixr 3 <<|> -- | Label a parser (>) :: IsParser p => p a -> String -> p a infix 2 > char :: (IsParser p, Eq (SymbolOf p), Show (SymbolOf p)) => SymbolOf p -> p (SymbolOf p) noneOf :: (IsParser p, SymbolOf p ~# Char) => [Char] -> p Char oneOf :: (IsParser p, SymbolOf p ~# Char) => [Char] -> p Char spaces :: (IsParser p, SymbolOf p ~# Char) => p () space :: (IsParser p, SymbolOf p ~# Char) => p Char newline :: (IsParser p, Eq (SymbolOf p), Show (SymbolOf p), SymbolOf p ~# Char) => p Char tab :: (IsParser p, Eq (SymbolOf p), Show (SymbolOf p), SymbolOf p ~# Char) => p Char upper :: (IsParser p, SymbolOf p ~# Char) => p Char lower :: (IsParser p, SymbolOf p ~# Char) => p Char alphaNum :: (IsParser p, SymbolOf p ~# Char) => p Char letter :: (IsParser p, SymbolOf p ~# Char) => p Char digit :: (IsParser p, SymbolOf p ~# Char) => p Char hexDigit :: (IsParser p, SymbolOf p ~# Char) => p Char octDigit :: (IsParser p, SymbolOf p ~# Char) => p Char anySymbol :: IsParser p => p (SymbolOf p) string :: (IsParser p, SymbolOf p ~ Char) => String -> p String choice :: Alternative f => [f a] -> f a option :: Alternative f => a -> f a -> f a between :: Applicative m => m x -> m y -> m a -> m a -- | Greedy repetition: match as many occurences as possible of the -- argument. manyGreedy :: IsParser m => m a -> m [a] skipMany1 :: Alternative f => f a -> f () skipMany :: Alternative f => f a -> f () sepBy :: Alternative f => f a1 -> f a2 -> f [a1] sepBy1 :: Alternative f => f a1 -> f a2 -> f [a1] count :: Applicative m => Int -> m a -> m [a] chainr :: (Alternative f, Monad f) => f a -> f (a -> a -> a) -> a -> f a chainl :: (Alternative f, Monad f) => f a -> f (a -> a -> a) -> a -> f a chainr1 :: (Monad f, Alternative f) => f t -> f (t -> t -> t) -> f t chainl1 :: (Alternative m, Monad m) => m b -> m (b -> b -> b) -> m b munch :: IsParser m => (SymbolOf m -> Bool) -> m [SymbolOf m] munch1 :: IsParser m => (SymbolOf m -> Bool) -> m [SymbolOf m] endOfFile :: IsParser p => p () type ParseResult s r = Either (Err s) r type ParseMethod s a r = P s a -> [s] -> ParseResult s r -- | An intersection (nesting) of things currently expected type Expect s = [(String, Maybe s)] mapErrR :: (s -> s') -> ParseResult s r -> ParseResult s' r shortestResult :: ParseMethod s a a longestResult :: ParseMethod s a a longestResults :: ParseMethod s a [a] allResultsStaged :: ParseMethod s a [[a]] allResults :: ParseMethod s a [a] completeResults :: ParseMethod s a [a] shortestResultWithLeftover :: ParseMethod s a (a, [s]) longestResultWithLeftover :: ParseMethod s a (a, [s]) longestResultsWithLeftover :: ParseMethod s a ([a], Maybe [s]) allResultsWithLeftover :: ParseMethod s a [(a, [s])] data SourcePos Loc :: !FilePath -> !Int -> !Int -> SourcePos [sourceName] :: SourcePos -> !FilePath [sourceLine] :: SourcePos -> !Int [sourceCol] :: SourcePos -> !Int EOF :: SourcePos data Parser a getPosition :: Parser SourcePos parse :: FilePath -> Parser a -> (forall s. ParseMethod s a r) -> String -> ParseResult SourcePos r parseFromFile :: Parser a -> (forall s. ParseMethod s a r) -> FilePath -> IO (ParseResult SourcePos r) maybePosToPos :: Maybe SourcePos -> SourcePos anyChar :: IsParser p => p (SymbolOf p) instance Control.Monad.Fail.MonadFail Text.ParserCombinators.Parsek.Position.Parser instance GHC.Base.MonadPlus Text.ParserCombinators.Parsek.Position.Parser instance GHC.Base.Functor Text.ParserCombinators.Parsek.Position.Parser instance GHC.Base.Monad Text.ParserCombinators.Parsek.Position.Parser instance GHC.Base.Applicative Text.ParserCombinators.Parsek.Position.Parser instance GHC.Base.Alternative Text.ParserCombinators.Parsek.Position.Parser instance GHC.Classes.Eq Text.ParserCombinators.Parsek.Position.SourcePos instance GHC.Classes.Ord Text.ParserCombinators.Parsek.Position.SourcePos instance Text.ParserCombinators.Class.IsParser Text.ParserCombinators.Parsek.Position.Parser instance GHC.Show.Show Text.ParserCombinators.Parsek.Position.SourcePos