| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.ParserCombinators.Parsek.Position
Synopsis
- guard :: Alternative f => Bool -> f ()
- (<$) :: Functor f => a -> f b -> f a
- class Functor f => Applicative (f :: Type -> Type) where
- optional :: Alternative f => f a -> f (Maybe a)
- newtype WrappedMonad (m :: Type -> Type) a = WrapMonad {
- unwrapMonad :: m a
- newtype WrappedArrow (a :: Type -> Type -> Type) b c = WrapArrow {
- unwrapArrow :: a b c
- newtype ZipList a = ZipList {
- getZipList :: [a]
- newtype Const a (b :: k) :: forall k. Type -> k -> Type = Const {
- getConst :: a
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- ap :: Monad m => m (a -> b) -> m a -> m b
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- liftA :: Applicative f => (a -> b) -> f a -> f b
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- class Applicative f => Alternative (f :: Type -> Type) where
- class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where
- class (Monad p, Alternative p) => IsParser p where
- (<?>) :: IsParser p => p a -> String -> p a
- 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
- 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
- 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])]
- module Text.ParserCombinators.Class
- data SourcePos
- = Loc {
- sourceName :: !FilePath
- sourceLine :: !Int
- sourceCol :: !Int
- | EOF
- = Loc {
- 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)
Documentation
guard :: Alternative f => Bool -> f () #
Conditional failure of Alternative computations. Defined by
guard True =pure() guard False =empty
Examples
Common uses of guard include conditionally signaling an error in
an error monad and conditionally rejecting the current choice in an
Alternative-based parser.
As an example of signaling an error in the error monad Maybe,
consider a safe division function safeDiv x y that returns
Nothing when the denominator y is zero and otherwise. For example:Just (x `div`
y)
>>> 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)
class Functor f => Applicative (f :: Type -> Type) where #
A functor with application, providing operations to
A minimal complete definition must include implementations of pure
and of either <*> or liftA2. If it defines both, then they must behave
the same as their default definitions:
(<*>) =liftA2id
liftA2f x y = f<$>x<*>y
Further, any definition must satisfy the following:
- identity
pureid<*>v = v- composition
pure(.)<*>u<*>v<*>w = u<*>(v<*>w)- homomorphism
puref<*>purex =pure(f x)- interchange
u
<*>purey =pure($y)<*>u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor instance for f will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2p (liftA2q u v) =liftA2f u .liftA2g v
If f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
Methods
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4 #
Sequential application.
A few functors support an implementation of <*> that is more
efficient than the default one.
liftA2 :: (a -> b -> c) -> f a -> f b -> f c #
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 <*>.
(*>) :: f a -> f b -> f b infixl 4 #
Sequence actions, discarding the value of the first argument.
(<*) :: f a -> f b -> f a infixl 4 #
Sequence actions, discarding the value of the second argument.
Instances
| Applicative [] | Since: base-2.1 |
| Applicative Maybe | Since: base-2.1 |
| Applicative IO | Since: base-2.1 |
| Applicative ZipList | f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
= 'ZipList' (zipWithN f xs1 ... xsN)where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
= ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
= ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Since: base-2.1 |
| Applicative ReadP | Since: base-4.6.0.0 |
| Applicative NonEmpty | Since: base-4.9.0.0 |
| Applicative P | Since: base-4.5.0.0 |
| Applicative Parser Source # | |
| Applicative (Either e) | Since: base-3.0 |
| Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002)
("hello world!",2017)Since: base-2.1 |
| Monad m => Applicative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # | |
| Arrow a => Applicative (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in Control.Arrow Methods pure :: a0 -> ArrowMonad a a0 # (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b # liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c # (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b # (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 # | |
| Applicative (Parser s) Source # | |
| Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
| Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
| Applicative ((->) a :: Type -> Type) | Since: base-2.1 |
optional :: Alternative f => f a -> f (Maybe a) #
One or none.
newtype WrappedMonad (m :: Type -> Type) a #
Constructors
| WrapMonad | |
Fields
| |
Instances
newtype WrappedArrow (a :: Type -> Type -> Type) b c #
Constructors
| WrapArrow | |
Fields
| |
Instances
| Generic1 (WrappedArrow a b :: Type -> Type) | |
Defined in Control.Applicative Associated Types type Rep1 (WrappedArrow a b) :: k -> Type # Methods from1 :: WrappedArrow a b a0 -> Rep1 (WrappedArrow a b) a0 # to1 :: Rep1 (WrappedArrow a b) a0 -> WrappedArrow a b a0 # | |
| Arrow a => Functor (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
| Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
| (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods empty :: WrappedArrow a b a0 # (<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 # some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # | |
| Generic (WrappedArrow a b c) | |
Defined in Control.Applicative Associated Types type Rep (WrappedArrow a b c) :: Type -> Type # Methods from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x # to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c # | |
| type Rep1 (WrappedArrow a b :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Control.Applicative type Rep1 (WrappedArrow a b :: Type -> Type) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 (a b)))) | |
| type Rep (WrappedArrow a b c) | Since: base-4.7.0.0 |
Defined in Control.Applicative type Rep (WrappedArrow a b c) = D1 (MetaData "WrappedArrow" "Control.Applicative" "base" True) (C1 (MetaCons "WrapArrow" PrefixI True) (S1 (MetaSel (Just "unwrapArrow") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (a b c)))) | |
Lists, but with an Applicative functor based on zipping.
Constructors
| ZipList | |
Fields
| |
Instances
| Functor ZipList | Since: base-2.1 |
| Applicative ZipList | f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
= 'ZipList' (zipWithN f xs1 ... xsN)where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
= ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
= ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Since: base-2.1 |
| Foldable ZipList | Since: base-4.9.0.0 |
Defined in Control.Applicative Methods fold :: Monoid m => ZipList m -> m # foldMap :: Monoid m => (a -> m) -> ZipList a -> m # foldr :: (a -> b -> b) -> b -> ZipList a -> b # foldr' :: (a -> b -> b) -> b -> ZipList a -> b # foldl :: (b -> a -> b) -> b -> ZipList a -> b # foldl' :: (b -> a -> b) -> b -> ZipList a -> b # foldr1 :: (a -> a -> a) -> ZipList a -> a # foldl1 :: (a -> a -> a) -> ZipList a -> a # elem :: Eq a => a -> ZipList a -> Bool # maximum :: Ord a => ZipList a -> a # minimum :: Ord a => ZipList a -> a # | |
| Traversable ZipList | Since: base-4.9.0.0 |
| Alternative ZipList | Since: base-4.11.0.0 |
| Eq a => Eq (ZipList a) | Since: base-4.7.0.0 |
| Ord a => Ord (ZipList a) | Since: base-4.7.0.0 |
| Read a => Read (ZipList a) | Since: base-4.7.0.0 |
| Show a => Show (ZipList a) | Since: base-4.7.0.0 |
| Generic (ZipList a) | |
| Generic1 ZipList | |
| type Rep (ZipList a) | Since: base-4.7.0.0 |
Defined in Control.Applicative | |
| type Rep1 ZipList | Since: base-4.7.0.0 |
Defined in Control.Applicative | |
newtype Const a (b :: k) :: forall k. Type -> k -> Type #
The Const functor.
Instances
| Generic1 (Const a :: k -> Type) | |
| Functor (Const m :: Type -> Type) | Since: base-2.1 |
| Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
| Foldable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # | |
| Traversable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
| Bounded a => Bounded (Const a b) | Since: base-4.9.0.0 |
| Enum a => Enum (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods succ :: Const a b -> Const a b # pred :: Const a b -> Const a b # fromEnum :: Const a b -> Int # enumFrom :: Const a b -> [Const a b] # enumFromThen :: Const a b -> Const a b -> [Const a b] # enumFromTo :: Const a b -> Const a b -> [Const a b] # enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] # | |
| Eq a => Eq (Const a b) | Since: base-4.9.0.0 |
| Floating a => Floating (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods exp :: Const a b -> Const a b # log :: Const a b -> Const a b # sqrt :: Const a b -> Const a b # (**) :: Const a b -> Const a b -> Const a b # logBase :: Const a b -> Const a b -> Const a b # sin :: Const a b -> Const a b # cos :: Const a b -> Const a b # tan :: Const a b -> Const a b # asin :: Const a b -> Const a b # acos :: Const a b -> Const a b # atan :: Const a b -> Const a b # sinh :: Const a b -> Const a b # cosh :: Const a b -> Const a b # tanh :: Const a b -> Const a b # asinh :: Const a b -> Const a b # acosh :: Const a b -> Const a b # atanh :: Const a b -> Const a b # log1p :: Const a b -> Const a b # expm1 :: Const a b -> Const a b # | |
| Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
| Integral a => Integral (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods quot :: Const a b -> Const a b -> Const a b # rem :: Const a b -> Const a b -> Const a b # div :: Const a b -> Const a b -> Const a b # mod :: Const a b -> Const a b -> Const a b # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) # divMod :: Const a b -> Const a b -> (Const a b, Const a b) # | |
| Num a => Num (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| Ord a => Ord (Const a b) | Since: base-4.9.0.0 |
| Read a => Read (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Real a => Real (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational # | |
| RealFloat a => RealFloat (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods floatRadix :: Const a b -> Integer # floatDigits :: Const a b -> Int # floatRange :: Const a b -> (Int, Int) # decodeFloat :: Const a b -> (Integer, Int) # encodeFloat :: Integer -> Int -> Const a b # exponent :: Const a b -> Int # significand :: Const a b -> Const a b # scaleFloat :: Int -> Const a b -> Const a b # isInfinite :: Const a b -> Bool # isDenormalized :: Const a b -> Bool # isNegativeZero :: Const a b -> Bool # | |
| RealFrac a => RealFrac (Const a b) | Since: base-4.9.0.0 |
| Show a => Show (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Ix a => Ix (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods range :: (Const a b, Const a b) -> [Const a b] # index :: (Const a b, Const a b) -> Const a b -> Int # unsafeIndex :: (Const a b, Const a b) -> Const a b -> Int inRange :: (Const a b, Const a b) -> Const a b -> Bool # rangeSize :: (Const a b, Const a b) -> Int # unsafeRangeSize :: (Const a b, Const a b) -> Int | |
| Generic (Const a b) | |
| Semigroup a => Semigroup (Const a b) | Since: base-4.9.0.0 |
| Monoid a => Monoid (Const a b) | Since: base-4.9.0.0 |
| Storable a => Storable (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| Bits a => Bits (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods (.&.) :: Const a b -> Const a b -> Const a b # (.|.) :: Const a b -> Const a b -> Const a b # xor :: Const a b -> Const a b -> Const a b # complement :: Const a b -> Const a b # shift :: Const a b -> Int -> Const a b # rotate :: Const a b -> Int -> Const a b # setBit :: Const a b -> Int -> Const a b # clearBit :: Const a b -> Int -> Const a b # complementBit :: Const a b -> Int -> Const a b # testBit :: Const a b -> Int -> Bool # bitSizeMaybe :: Const a b -> Maybe Int # isSigned :: Const a b -> Bool # shiftL :: Const a b -> Int -> Const a b # unsafeShiftL :: Const a b -> Int -> Const a b # shiftR :: Const a b -> Int -> Const a b # unsafeShiftR :: Const a b -> Int -> Const a b # rotateL :: Const a b -> Int -> Const a b # | |
| FiniteBits a => FiniteBits (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods finiteBitSize :: Const a b -> Int # countLeadingZeros :: Const a b -> Int # countTrailingZeros :: Const a b -> Int # | |
| type Rep1 (Const a :: k -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| type Rep (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #
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.
Examples
Convert from a to a Maybe Int using Maybe Stringshow:
>>>show <$> NothingNothing>>>show <$> Just 3Just "3"
Convert from an to an Either Int IntEither IntString using show:
>>>show <$> Left 17Left 17>>>show <$> Right 17Right "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)
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d #
Lift a ternary function to actions.
liftA :: Applicative f => (a -> b) -> f a -> f b #
(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 #
A variant of <*> with the arguments reversed.
class Applicative f => Alternative (f :: Type -> Type) where #
A monoid on applicative functors.
If defined, some and many should be the least solutions
of the equations:
Methods
The identity of <|>
(<|>) :: f a -> f a -> f a infixl 3 #
An associative binary operation
One or more.
Zero or more.
Instances
class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where #
Monads that also support choice and failure.
Minimal complete definition
Nothing
Methods
The identity of mplus. It should also satisfy the equations
mzero >>= f = mzero v >> mzero = mzero
The default definition is
mzero = empty
An associative operation. The default definition is
mplus = (<|>)
Instances
| MonadPlus [] | Since: base-2.1 |
| MonadPlus Maybe | Since: base-2.1 |
| MonadPlus IO | Since: base-4.9.0.0 |
| MonadPlus ReadP | Since: base-2.1 |
| MonadPlus P | Since: base-2.1 |
Defined in Text.ParserCombinators.ReadP | |
| MonadPlus Parser Source # | |
| (ArrowApply a, ArrowPlus a) => MonadPlus (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in Control.Arrow | |
| MonadPlus (Parser s) Source # | |
class (Monad p, Alternative p) => IsParser p where Source #
Parser class
Methods
Arguments
| :: p [SymbolOf p] | access the stream of symbols from the current point |
Arguments
| :: String | |
| -> p a | |
| -> p a | label the parser |
Arguments
| :: p a | |
| -> p a | |
| -> p a | Left-biased choice. |
Instances
| IsParser Parser Source # | |
Defined in Text.ParserCombinators.Parsek.Position | |
| IsParser (Parser s) Source # | |
Defined in Text.ParserCombinators.Parsek | |
choice :: Alternative f => [f a] -> f a Source #
option :: Alternative f => a -> f a -> f a Source #
between :: Applicative m => m x -> m y -> m a -> m a Source #
manyGreedy :: IsParser m => m a -> m [a] Source #
Greedy repetition: match as many occurences as possible of the argument.
skipMany1 :: Alternative f => f a -> f () Source #
skipMany :: Alternative f => f a -> f () Source #
sepBy :: Alternative f => f a1 -> f a2 -> f [a1] Source #
sepBy1 :: Alternative f => f a1 -> f a2 -> f [a1] Source #
count :: Applicative m => Int -> m a -> m [a] Source #
chainr :: (Alternative f, Monad f) => f a -> f (a -> a -> a) -> a -> f a Source #
chainl :: (Alternative f, Monad f) => f a -> f (a -> a -> a) -> a -> f a Source #
chainr1 :: (Monad f, Alternative f) => f t -> f (t -> t -> t) -> f t Source #
chainl1 :: (Alternative m, Monad m) => m b -> m (b -> b -> b) -> m b Source #
type ParseResult s r = Either (Err s) r Source #
type ParseMethod s a r = P s a -> [s] -> ParseResult s r Source #
mapErrR :: (s -> s') -> ParseResult s r -> ParseResult s' r Source #
shortestResult :: ParseMethod s a a Source #
longestResult :: ParseMethod s a a Source #
longestResults :: ParseMethod s a [a] Source #
allResultsStaged :: ParseMethod s a [[a]] Source #
allResults :: ParseMethod s a [a] Source #
completeResults :: ParseMethod s a [a] Source #
shortestResultWithLeftover :: ParseMethod s a (a, [s]) Source #
longestResultWithLeftover :: ParseMethod s a (a, [s]) Source #
longestResultsWithLeftover :: ParseMethod s a ([a], Maybe [s]) Source #
allResultsWithLeftover :: ParseMethod s a [(a, [s])] Source #
module Text.ParserCombinators.Class
Constructors
| Loc | |
Fields
| |
| EOF | |
Instances
| Eq SourcePos Source # | |
| Ord SourcePos Source # | |
Defined in Text.ParserCombinators.Parsek.Position | |
| Show SourcePos Source # | |
Instances
| Monad Parser Source # | |
| Functor Parser Source # | |
| MonadFail Parser Source # | |
Defined in Text.ParserCombinators.Parsek.Position | |
| Applicative Parser Source # | |
| Alternative Parser Source # | |
| MonadPlus Parser Source # | |
| IsParser Parser Source # | |
Defined in Text.ParserCombinators.Parsek.Position | |
| type SymbolOf Parser Source # | |
Defined in Text.ParserCombinators.Parsek.Position | |
parse :: FilePath -> Parser a -> (forall s. ParseMethod s a r) -> String -> ParseResult SourcePos r Source #
parseFromFile :: Parser a -> (forall s. ParseMethod s a r) -> FilePath -> IO (ParseResult SourcePos r) Source #