| Copyright | (c) Matthew Sackman Ivan Lazar Miljenovic |
|---|---|
| License | 3-Clause BSD-style |
| Maintainer | Ivan.Miljenovic@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.GraphViz.Parsing
Description
This module defines simple helper functions for use with Text.ParserCombinators.Poly.Lazy.
Note that the ParseDot instances for Bool, etc. match those
specified for use with Graphviz (e.g. non-zero integers are
equivalent to True).
You should not be using this module; rather, it is here for
informative/documentative reasons. If you want to parse a
, you should use
DotRepr rather than its parseDotGraphParseDot
instance.
Synopsis
- class Functor f => Applicative (f :: Type -> Type) where
- class Applicative f => Alternative (f :: Type -> Type) where
- (<$) :: Functor f => a -> f b -> f a
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- liftA :: Applicative f => (a -> b) -> f a -> f b
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- satisfy :: (Char -> Bool) -> Parser s Char
- eof :: Parser s ()
- optional :: Alternative f => f a -> f (Maybe a)
- many1 :: PolyParse p => p a -> p [a]
- sepBy :: PolyParse p => p a -> p sep -> p [a]
- sepBy1 :: PolyParse p => p a -> p sep -> p [a]
- apply :: PolyParse p => p (a -> b) -> p a -> p b
- asum :: (Foldable t, Alternative f) => t (f a) -> f a
- newtype Const a (b :: k) = Const {
- getConst :: a
- bracket :: PolyParse p => p bra -> p ket -> p a -> p a
- newtype ZipList a = ZipList {
- getZipList :: [a]
- newtype WrappedArrow (a :: Type -> Type -> Type) b c = WrapArrow {
- unwrapArrow :: a b c
- newtype WrappedMonad (m :: Type -> Type) a = WrapMonad {
- unwrapMonad :: m a
- newtype Parser s a = P (s -> Text -> Result (Text, s) a)
- data Result z a
- reparse :: Text -> Parser s ()
- class (Functor p, Monad p, MonadFail p, Applicative p, Alternative p, Commitment p) => PolyParse (p :: Type -> Type)
- class Commitment (p :: Type -> Type) where
- discard :: PolyParse p => p a -> p b -> p a
- failBad :: PolyParse p => String -> p a
- adjustErrBad :: PolyParse p => p a -> (String -> String) -> p a
- oneOf :: PolyParse p => [p a] -> p a
- exactly :: PolyParse p => Int -> p a -> p [a]
- upto :: PolyParse p => Int -> p a -> p [a]
- bracketSep :: PolyParse p => p bra -> p sep -> p ket -> p a -> p [a]
- manyFinally :: PolyParse p => p a -> p z -> p [a]
- manyFinally' :: (PolyParse p, Show a) => p a -> p z -> p [a]
- onFail :: Parser s a -> Parser s a -> Parser s a
- next :: Parser s Char
- manySatisfy :: (Char -> Bool) -> Parser s Text
- many1Satisfy :: (Char -> Bool) -> Parser s Text
- stUpdate :: (s -> s) -> Parser s ()
- stQuery :: (s -> a) -> Parser s a
- stGet :: Parser s s
- type Parse a = Parser GraphvizState a
- class ParseDot a where
- parseIt :: ParseDot a => Text -> (a, Text)
- parseIt' :: ParseDot a => Text -> a
- runParser :: Parse a -> Text -> (Either String a, Text)
- runParser' :: Parse a -> Text -> a
- runParserWith :: (GraphvizState -> GraphvizState) -> Parse a -> Text -> (Either String a, Text)
- parseLiberally :: GraphvizState -> GraphvizState
- checkValidParse :: Either String a -> a
- checkValidParseWithRest :: (Either String a, Text) -> a
- ignoreSep :: (a -> b -> c) -> Parse a -> Parse sep -> Parse b -> Parse c
- onlyBool :: Parse Bool
- quotelessString :: Parse Text
- stringBlock :: Parse Text
- numString :: Bool -> Parse Text
- isNumString :: Bool -> Text -> Bool
- isIntString :: Text -> Bool
- quotedString :: Parse Text
- parseEscaped :: Bool -> [Char] -> [Char] -> Parse Text
- parseAndSpace :: Parse a -> Parse a
- string :: String -> Parse ()
- strings :: [String] -> Parse ()
- character :: Char -> Parse Char
- parseStrictFloat :: Bool -> Parse Double
- parseSignedFloat :: Bool -> Parse Double
- noneOf :: [Char] -> Parse Char
- whitespace1 :: Parse ()
- whitespace :: Parse ()
- wrapWhitespace :: Parse a -> Parse a
- optionalQuotedString :: String -> Parse ()
- optionalQuoted :: Parse a -> Parse a
- quotedParse :: Parse a -> Parse a
- orQuote :: Parse Char -> Parse Char
- quoteChar :: Char
- newline :: Parse ()
- newline' :: Parse ()
- parseComma :: Parse ()
- parseEq :: Parse ()
- tryParseList :: ParseDot a => Parse [a]
- tryParseList' :: Parse [a] -> Parse [a]
- consumeLine :: Parse Text
- commaSep :: (ParseDot a, ParseDot b) => Parse (a, b)
- commaSepUnqt :: (ParseDot a, ParseDot b) => Parse (a, b)
- commaSep' :: Parse a -> Parse b -> Parse (a, b)
- stringRep :: a -> String -> Parse a
- stringReps :: a -> [String] -> Parse a
- stringParse :: [(String, Parse a)] -> Parse a
- stringValue :: [(String, a)] -> Parse a
- parseAngled :: Parse a -> Parse a
- parseBraced :: Parse a -> Parse a
- parseColorScheme :: Bool -> Parse ColorScheme
Re-exporting pertinent parts of Polyparse.
class Functor f => Applicative (f :: Type -> Type) where Source #
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 into the Structure.
Examples
>>>pure 1 :: Maybe IntJust 1
>>>pure 'z' :: [Char]"z"
>>>pure (pure ":D") :: Maybe [String]Just [":D"]
(<*>) :: f (a -> b) -> f a -> f b infixl 4 Source #
Sequential application.
A few functors support an implementation of <*> that is more
efficient than the default one.
Example
Used in combination with , (<$>) can be used to build a record.(<*>)
>>>data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>>produceFoo :: Applicative f => f Foo>>>produceBar :: Applicative f => f Bar>>>produceBaz :: Applicative f => f Baz
>>>mkState :: Applicative f => f MyState>>>mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
liftA2 :: (a -> b -> c) -> f a -> f b -> f c Source #
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 <*>.
This became a typeclass method in 4.10.0.0. Prior to that, it was
a function defined in terms of <*> and fmap.
Example
>>>liftA2 (,) (Just 3) (Just 5)Just (3,5)
>>>liftA2 (+) [1, 2, 3] [4, 5, 6][5,6,7,6,7,8,7,8,9]
(*>) :: f a -> f b -> f b infixl 4 Source #
Sequence actions, discarding the value of the first argument.
Examples
If used in conjunction with the Applicative instance for Maybe,
you can chain Maybe computations, with a possible "early return"
in case of Nothing.
>>>Just 2 *> Just 3Just 3
>>>Nothing *> Just 3Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
>>>import Data.Char>>>import GHC.Internal.Text.ParserCombinators.ReadP>>>let p = string "my name is " *> munch1 isAlpha <* eof>>>readP_to_S p "my name is Simon"[("Simon","")]
(<*) :: f a -> f b -> f a infixl 4 Source #
Sequence actions, discarding the value of the second argument.
Instances
| Applicative Complex | Since: base-4.9.0.0 |
| Applicative First | Since: base-4.9.0.0 |
| Applicative Last | Since: base-4.9.0.0 |
| Applicative Max | Since: base-4.9.0.0 |
| Applicative Min | Since: base-4.9.0.0 |
| Applicative Put | |
| Applicative RGB | |
| Applicative Seq | Since: containers-0.5.4 |
| Applicative Tree | |
| Applicative DList | |
| Applicative NonEmpty | Since: base-4.9.0.0 |
Defined in GHC.Internal.Base | |
| Applicative STM | Since: base-4.8.0.0 |
| Applicative Identity | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Functor.Identity | |
| 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 |
Defined in GHC.Internal.Functor.ZipList | |
| Applicative Par1 | Since: base-4.9.0.0 |
| Applicative P | Since: base-4.5.0.0 |
| Applicative ReadP | Since: base-4.6.0.0 |
Defined in GHC.Internal.Text.ParserCombinators.ReadP | |
| Applicative ReadPrec | Since: base-4.6.0.0 |
Defined in GHC.Internal.Text.ParserCombinators.ReadPrec | |
| Applicative IO | Since: base-2.1 |
| Applicative DotCodeM Source # | |
Defined in Data.GraphViz.Printing | |
| Applicative Parser | |
Defined in Text.ParserCombinators.HuttonMeijer | |
| Applicative Parser | |
Defined in Text.ParserCombinators.Poly.ByteString | |
| Applicative Parser | |
Defined in Text.ParserCombinators.Poly.ByteStringChar | |
| Applicative Parser | |
Defined in Text.ParserCombinators.Poly.Text | |
| Applicative Q | |
| Applicative Maybe | Since: base-2.1 |
| Applicative Solo | Since: base-4.15 |
| Applicative [] | Since: base-2.1 |
| Monad m => Applicative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a -> WrappedMonad m a Source # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # | |
| Applicative (SetM s) | |
| Arrow a => Applicative (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in GHC.Internal.Control.Arrow Methods pure :: a0 -> ArrowMonad a a0 Source # (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source # liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c Source # (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source # (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 Source # | |
| Applicative (Either e) | Since: base-3.0 |
Defined in GHC.Internal.Data.Either | |
| Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
| Applicative (DotM n) Source # | |
| Applicative (Parser t) | |
Defined in Text.ParserCombinators.Poly.Lazy | |
| Applicative (Parser t) | |
Defined in Text.ParserCombinators.Poly.Lex | |
| Applicative (Parser t) | |
Defined in Text.ParserCombinators.Poly.Parser | |
| Applicative (Parser s) | |
Defined in Text.ParserCombinators.Poly.StateText | |
| Applicative (IParser t) | |
Defined in Data.Text.Internal.Read | |
| (Functor m, Monad m) => Applicative (MaybeT m) | |
Defined in Control.Monad.Trans.Maybe | |
| Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002)
("hello world!",2017)Since: base-2.1 |
| Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 Source # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # | |
| (Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods pure :: a -> WhenMissing f x a Source # (<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b Source # liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c Source # (*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b Source # (<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a Source # | |
| Monad m => Applicative (GT m g) | |
Defined in Data.Graph.Inductive.Query.Monad | |
| Applicative m => Applicative (Kleisli m a) | Since: base-4.14.0.0 |
Defined in GHC.Internal.Control.Arrow Methods pure :: a0 -> Kleisli m a a0 Source # (<*>) :: Kleisli m a (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source # liftA2 :: (a0 -> b -> c) -> Kleisli m a a0 -> Kleisli m a b -> Kleisli m a c Source # (*>) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a b Source # (<*) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a a0 Source # | |
| Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
Defined in GHC.Internal.Data.Functor.Const | |
| (Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f) | Since: base-4.17.0.0 |
Defined in GHC.Internal.Generics Methods pure :: a -> Generically1 f a Source # (<*>) :: Generically1 f (a -> b) -> Generically1 f a -> Generically1 f b Source # liftA2 :: (a -> b -> c) -> Generically1 f a -> Generically1 f b -> Generically1 f c Source # (*>) :: Generically1 f a -> Generically1 f b -> Generically1 f b Source # (<*) :: Generically1 f a -> Generically1 f b -> Generically1 f a Source # | |
| Applicative f => Applicative (Rec1 f) | Since: base-4.9.0.0 |
| Applicative (t m) => Applicative (LiftingAccum t m) | Since: mtl-2.3 |
Defined in Control.Monad.Accum Methods pure :: a -> LiftingAccum t m a Source # (<*>) :: LiftingAccum t m (a -> b) -> LiftingAccum t m a -> LiftingAccum t m b Source # liftA2 :: (a -> b -> c) -> LiftingAccum t m a -> LiftingAccum t m b -> LiftingAccum t m c Source # (*>) :: LiftingAccum t m a -> LiftingAccum t m b -> LiftingAccum t m b Source # (<*) :: LiftingAccum t m a -> LiftingAccum t m b -> LiftingAccum t m a Source # | |
| Applicative (t m) => Applicative (LiftingSelect t m) | Since: mtl-2.3 |
Defined in Control.Monad.Select Methods pure :: a -> LiftingSelect t m a Source # (<*>) :: LiftingSelect t m (a -> b) -> LiftingSelect t m a -> LiftingSelect t m b Source # liftA2 :: (a -> b -> c) -> LiftingSelect t m a -> LiftingSelect t m b -> LiftingSelect t m c Source # (*>) :: LiftingSelect t m a -> LiftingSelect t m b -> LiftingSelect t m b Source # (<*) :: LiftingSelect t m a -> LiftingSelect t m b -> LiftingSelect t m a Source # | |
| Applicative (Parser s t) | |
Defined in Text.ParserCombinators.Poly.StateLazy Methods pure :: a -> Parser s t a Source # (<*>) :: Parser s t (a -> b) -> Parser s t a -> Parser s t b Source # liftA2 :: (a -> b -> c) -> Parser s t a -> Parser s t b -> Parser s t c Source # (*>) :: Parser s t a -> Parser s t b -> Parser s t b Source # (<*) :: Parser s t a -> Parser s t b -> Parser s t a Source # | |
| Applicative (Parser s t) | |
Defined in Text.ParserCombinators.Poly.StateParser Methods pure :: a -> Parser s t a Source # (<*>) :: Parser s t (a -> b) -> Parser s t a -> Parser s t b Source # liftA2 :: (a -> b -> c) -> Parser s t a -> Parser s t b -> Parser s t c Source # (*>) :: Parser s t a -> Parser s t b -> Parser s t b Source # (<*) :: Parser s t a -> Parser s t b -> Parser s t a Source # | |
| (Monoid w, Functor m, Monad m) => Applicative (AccumT w m) | |
Defined in Control.Monad.Trans.Accum Methods pure :: a -> AccumT w m a Source # (<*>) :: AccumT w m (a -> b) -> AccumT w m a -> AccumT w m b Source # liftA2 :: (a -> b -> c) -> AccumT w m a -> AccumT w m b -> AccumT w m c Source # (*>) :: AccumT w m a -> AccumT w m b -> AccumT w m b Source # (<*) :: AccumT w m a -> AccumT w m b -> AccumT w m a Source # | |
| (Functor m, Monad m) => Applicative (ExceptT e m) | |
Defined in Control.Monad.Trans.Except Methods pure :: a -> ExceptT e m a Source # (<*>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b Source # liftA2 :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c Source # (*>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b Source # (<*) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a Source # | |
| Applicative m => Applicative (IdentityT m) | |
Defined in Control.Monad.Trans.Identity Methods pure :: a -> IdentityT m a Source # (<*>) :: IdentityT m (a -> b) -> IdentityT m a -> IdentityT m b Source # liftA2 :: (a -> b -> c) -> IdentityT m a -> IdentityT m b -> IdentityT m c Source # (*>) :: IdentityT m a -> IdentityT m b -> IdentityT m b Source # (<*) :: IdentityT m a -> IdentityT m b -> IdentityT m a Source # | |
| Applicative m => Applicative (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader Methods pure :: a -> ReaderT r m a Source # (<*>) :: ReaderT r m (a -> b) -> ReaderT r m a -> ReaderT r m b Source # liftA2 :: (a -> b -> c) -> ReaderT r m a -> ReaderT r m b -> ReaderT r m c Source # (*>) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m b Source # (<*) :: ReaderT r m a -> ReaderT r m b -> ReaderT r m a Source # | |
| (Functor m, Monad m) => Applicative (SelectT r m) | |
Defined in Control.Monad.Trans.Select Methods pure :: a -> SelectT r m a Source # (<*>) :: SelectT r m (a -> b) -> SelectT r m a -> SelectT r m b Source # liftA2 :: (a -> b -> c) -> SelectT r m a -> SelectT r m b -> SelectT r m c Source # (*>) :: SelectT r m a -> SelectT r m b -> SelectT r m b Source # (<*) :: SelectT r m a -> SelectT r m b -> SelectT r m a Source # | |
| (Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Lazy Methods pure :: a -> StateT s m a Source # (<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source # liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source # (*>) :: StateT s m a -> StateT s m b -> StateT s m b Source # (<*) :: StateT s m a -> StateT s m b -> StateT s m a Source # | |
| (Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict Methods pure :: a -> StateT s m a Source # (<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source # liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source # (*>) :: StateT s m a -> StateT s m b -> StateT s m b Source # (<*) :: StateT s m a -> StateT s m b -> StateT s m a Source # | |
| (Functor m, Monad m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.CPS Methods pure :: a -> WriterT w m a Source # (<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source # liftA2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source # (*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source # (<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # | |
| (Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Lazy Methods pure :: a -> WriterT w m a Source # (<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source # liftA2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source # (*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source # (<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # | |
| (Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Strict Methods pure :: a -> WriterT w m a Source # (<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source # liftA2 :: (a -> b -> c) -> WriterT w m a -> WriterT w m b -> WriterT w m c Source # (*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b Source # (<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a Source # | |
| (Monoid a, Monoid b) => Applicative ((,,) a b) | Since: base-4.14.0.0 |
Defined in GHC.Internal.Base | |
| (Applicative f, Applicative g) => Applicative (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methods pure :: a -> Product f g a Source # (<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b Source # liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source # (*>) :: Product f g a -> Product f g b -> Product f g b Source # (<*) :: Product f g a -> Product f g b -> Product f g a Source # | |
| (Monad f, Applicative f) => Applicative (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods pure :: a -> WhenMatched f x y a Source # (<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b Source # liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c Source # (*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b Source # (<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a Source # | |
| (Applicative f, Monad f) => Applicative (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods pure :: a -> WhenMissing f k x a Source # (<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b Source # liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c Source # (*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b Source # (<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a Source # | |
| (Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
| Monoid c => Applicative (K1 i c :: Type -> Type) | Since: base-4.12.0.0 |
| Applicative (Parser s t e) | |
Defined in Text.ParserCombinators.HuttonMeijerWallace Methods pure :: a -> Parser s t e a Source # (<*>) :: Parser s t e (a -> b) -> Parser s t e a -> Parser s t e b Source # liftA2 :: (a -> b -> c) -> Parser s t e a -> Parser s t e b -> Parser s t e c Source # (*>) :: Parser s t e a -> Parser s t e b -> Parser s t e b Source # (<*) :: Parser s t e a -> Parser s t e b -> Parser s t e a Source # | |
| Applicative (ContT r m) | |
Defined in Control.Monad.Trans.Cont | |
| (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) | Since: base-4.14.0.0 |
Defined in GHC.Internal.Base Methods pure :: a0 -> (a, b, c, a0) Source # (<*>) :: (a, b, c, a0 -> b0) -> (a, b, c, a0) -> (a, b, c, b0) Source # liftA2 :: (a0 -> b0 -> c0) -> (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, c0) Source # (*>) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, b0) Source # (<*) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, a0) Source # | |
| Applicative ((->) r) | Since: base-2.1 |
| (Applicative f, Applicative g) => Applicative (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methods pure :: a -> Compose f g a Source # (<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b Source # liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source # (*>) :: Compose f g a -> Compose f g b -> Compose f g b Source # (<*) :: Compose f g a -> Compose f g b -> Compose f g a Source # | |
| (Monad f, Applicative f) => Applicative (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods pure :: a -> WhenMatched f k x y a Source # (<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b Source # liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c Source # (*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b Source # (<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a Source # | |
| (Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
| Applicative f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
| (Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.CPS Methods pure :: a -> RWST r w s m a Source # (<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source # liftA2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source # (*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source # (<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # | |
| (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Lazy Methods pure :: a -> RWST r w s m a Source # (<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source # liftA2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source # (*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source # (<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # | |
| (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Strict Methods pure :: a -> RWST r w s m a Source # (<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b Source # liftA2 :: (a -> b -> c) -> RWST r w s m a -> RWST r w s m b -> RWST r w s m c Source # (*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b Source # (<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source # | |
class Applicative f => Alternative (f :: Type -> Type) where Source #
A monoid on applicative functors.
If defined, some and many should be the least solutions
of the equations:
Examples
>>>Nothing <|> Just 42Just 42
>>>[1, 2] <|> [3, 4][1,2,3,4]
>>>empty <|> print (2^15)32768
Methods
(<|>) :: f a -> f a -> f a infixl 3 Source #
An associative binary operation
One or more.
Examples
>>>some (putStr "la")lalalalalalalalala... * goes on forever *
>>>some Nothingnothing
>>>take 5 <$> some (Just 1)* hangs forever *
Note that this function can be used with Parsers based on
Applicatives. In that case some parser will attempt to
parse parser one or more times until it fails.
Zero or more.
Examples
>>>many (putStr "la")lalalalalalalalala... * goes on forever *
>>>many NothingJust []
>>>take 5 <$> many (Just 1)* hangs forever *
Note that this function can be used with Parsers based on
Applicatives. In that case many parser will attempt to
parse parser zero or more times until it fails.
Instances
(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 Source #
A variant of <*> with the types of the arguments reversed. It differs from
in that the effects are resolved in the order the arguments are
presented.flip (<*>)
Examples
>>>(<**>) (print 1) (id <$ print 2)1 2
>>>flip (<*>) (print 1) (id <$ print 2)2 1
>>>ZipList [4, 5, 6] <**> ZipList [(+1), (*2), (/3)]ZipList {getZipList = [5.0,10.0,2.0]}
liftA :: Applicative f => (a -> b) -> f a -> f b Source #
Lift a function to actions.
Equivalent to Functor's fmap but implemented using only Applicative's methods:
liftA f a = pure f <*> a
As such this function may be used to implement a Functor instance from an Applicative one.
Examples
Using the Applicative instance for Lists:
>>>liftA (+1) [1, 2][2,3]
Or the Applicative instance for Maybe
>>>liftA (+1) (Just 3)Just 4
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d Source #
Lift a ternary function to actions.
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source #
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)
satisfy :: (Char -> Bool) -> Parser s Char Source #
Return the next token if it satisfies the given predicate.
optional :: Alternative f => f a -> f (Maybe a) Source #
One or none.
It is useful for modelling any computation that is allowed to fail.
Examples
Using the Alternative instance of Control.Monad.Except, the following functions:
>>>import Control.Monad.Except
>>>canFail = throwError "it failed" :: Except String Int>>>final = return 42 :: Except String Int
Can be combined by allowing the first function to fail:
>>>runExcept $ canFail *> finalLeft "it failed"
>>>runExcept $ optional canFail *> finalRight 42
sepBy :: PolyParse p => p a -> p sep -> p [a] Source #
Parse a list of items separated by discarded junk.
sepBy1 :: PolyParse p => p a -> p sep -> p [a] Source #
Parse a non-empty list of items separated by discarded junk.
apply :: PolyParse p => p (a -> b) -> p a -> p b infixl 3 Source #
Apply a parsed function to a parsed value. Rather like ordinary function application lifted into parsers.
asum :: (Foldable t, Alternative f) => t (f a) -> f a Source #
The sum of a collection of actions using (<|>), generalizing concat.
asum is just like msum, but generalised to Alternative.
Examples
Basic usage:
>>>asum [Just "Hello", Nothing, Just "World"]Just "Hello"
newtype Const a (b :: k) Source #
The Const functor.
Examples
>>>fmap (++ "World") (Const "Hello")Const "Hello"
Because we ignore the second type parameter to Const,
the Applicative instance, which has
essentially turns into (<*>) :: Monoid m => Const m (a -> b) -> Const m a -> Const m bMonoid m => m -> m -> m, which is (<>)
>>>Const [1, 2, 3] <*> Const [4, 5, 6]Const [1,2,3,4,5,6]
Instances
bracket :: PolyParse p => p bra -> p ket -> p a -> p a Source #
Parse a bracketed item, discarding the brackets.
If everything matches except the closing bracket, the whole
parse fails soft, which can give less-than-satisfying error messages.
If you want better error messages, try calling with e.g.
bracket open (commit close) item
Lists, but with an Applicative functor based on zipping.
Examples
In contrast to the Applicative for List:
>>>(+) <$> [1, 2, 3] <*> [4, 5, 6][5,6,7,6,7,8,7,8,9]
The Applicative instance of ZipList applies the operation
by pairing up the elements, analogous to zipWithN
>>>(+) <$> ZipList [1, 2, 3] <*> ZipList [4, 5, 6]ZipList {getZipList = [5,7,9]}
>>>(,,,) <$> ZipList [1, 2] <*> ZipList [3, 4] <*> ZipList [5, 6] <*> ZipList [7, 8]ZipList {getZipList = [(1,3,5,7),(2,4,6,8)]}
>>>ZipList [(+1), (^2), (/ 2)] <*> ZipList [5, 5, 5]ZipList {getZipList = [6.0,25.0,2.5]}
Constructors
| ZipList | |
Fields
| |
Instances
| NFData1 ZipList | Since: deepseq-1.4.3.0 | ||||
Defined in Control.DeepSeq | |||||
| Alternative ZipList | Since: base-4.11.0.0 | ||||
| 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 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
| Functor ZipList | Since: base-2.1 | ||||
| Foldable ZipList | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList Methods fold :: Monoid m => ZipList m -> m Source # foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m Source # foldr :: (a -> b -> b) -> b -> ZipList a -> b Source # foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source # foldl :: (b -> a -> b) -> b -> ZipList a -> b Source # foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source # foldr1 :: (a -> a -> a) -> ZipList a -> a Source # foldl1 :: (a -> a -> a) -> ZipList a -> a Source # toList :: ZipList a -> [a] Source # null :: ZipList a -> Bool Source # length :: ZipList a -> Int Source # elem :: Eq a => a -> ZipList a -> Bool Source # maximum :: Ord a => ZipList a -> a Source # minimum :: Ord a => ZipList a -> a Source # | |||||
| Traversable ZipList | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
| Generic1 ZipList | |||||
Defined in GHC.Internal.Functor.ZipList Associated Types
| |||||
| NFData a => NFData (ZipList a) | Since: deepseq-1.4.0.0 | ||||
Defined in Control.DeepSeq | |||||
| Data a => Data (ZipList a) | Since: base-4.14.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ZipList a -> c (ZipList a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ZipList a) Source # toConstr :: ZipList a -> Constr Source # dataTypeOf :: ZipList a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ZipList a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ZipList a)) Source # gmapT :: (forall b. Data b => b -> b) -> ZipList a -> ZipList a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ZipList a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ZipList a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> ZipList a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> ZipList a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) Source # | |||||
| Generic (ZipList a) | |||||
Defined in GHC.Internal.Functor.ZipList Associated Types
| |||||
| IsList (ZipList a) | Since: base-4.15.0.0 | ||||
| Read a => Read (ZipList a) | Since: base-4.7.0.0 | ||||
| Show a => Show (ZipList a) | Since: base-4.7.0.0 | ||||
| Eq a => Eq (ZipList a) | Since: base-4.7.0.0 | ||||
| Ord a => Ord (ZipList a) | Since: base-4.7.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
| type Rep1 ZipList | Since: base-4.7.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
| type Rep (ZipList a) | Since: base-4.7.0.0 | ||||
Defined in GHC.Internal.Functor.ZipList | |||||
| type Item (ZipList a) | |||||
Defined in GHC.Internal.IsList | |||||
newtype WrappedArrow (a :: Type -> Type -> Type) b c Source #
Constructors
| WrapArrow | |
Fields
| |
Instances
| Generic1 (WrappedArrow a b :: Type -> Type) | |||||
Defined in Control.Applicative Associated Types
Methods from1 :: WrappedArrow a b a0 -> Rep1 (WrappedArrow a b) a0 Source # to1 :: Rep1 (WrappedArrow a b) a0 -> WrappedArrow a b a0 Source # | |||||
| (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) | Since: base-2.1 | ||||
Defined in Control.Applicative Methods empty :: WrappedArrow a b a0 Source # (<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 Source # some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] Source # many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] Source # | |||||
| Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 | ||||
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 Source # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # | |||||
| 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 Source # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # | |||||
| (Typeable a, Typeable b, Typeable c, Data (a b c)) => Data (WrappedArrow a b c) | Since: base-4.14.0.0 | ||||
Defined in Control.Applicative Methods gfoldl :: (forall d b0. Data d => c0 (d -> b0) -> d -> c0 b0) -> (forall g. g -> c0 g) -> WrappedArrow a b c -> c0 (WrappedArrow a b c) Source # gunfold :: (forall b0 r. Data b0 => c0 (b0 -> r) -> c0 r) -> (forall r. r -> c0 r) -> Constr -> c0 (WrappedArrow a b c) Source # toConstr :: WrappedArrow a b c -> Constr Source # dataTypeOf :: WrappedArrow a b c -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c0 (t d)) -> Maybe (c0 (WrappedArrow a b c)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c0 (t d e)) -> Maybe (c0 (WrappedArrow a b c)) Source # gmapT :: (forall b0. Data b0 => b0 -> b0) -> WrappedArrow a b c -> WrappedArrow a b c Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WrappedArrow a b c -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WrappedArrow a b c -> r Source # gmapQ :: (forall d. Data d => d -> u) -> WrappedArrow a b c -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> WrappedArrow a b c -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> WrappedArrow a b c -> m (WrappedArrow a b c) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WrappedArrow a b c -> m (WrappedArrow a b c) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WrappedArrow a b c -> m (WrappedArrow a b c) Source # | |||||
| Generic (WrappedArrow a b c) | |||||
Defined in Control.Applicative Associated Types
Methods from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x Source # to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c Source # | |||||
| 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)))) | |||||
newtype WrappedMonad (m :: Type -> Type) a Source #
Constructors
| WrapMonad | |
Fields
| |
Instances
| Generic1 (WrappedMonad m :: Type -> Type) | |||||
Defined in Control.Applicative Associated Types
Methods from1 :: WrappedMonad m a -> Rep1 (WrappedMonad m) a Source # to1 :: Rep1 (WrappedMonad m) a -> WrappedMonad m a Source # | |||||
| MonadPlus m => Alternative (WrappedMonad m) | Since: base-2.1 | ||||
Defined in Control.Applicative Methods empty :: WrappedMonad m a Source # (<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a Source # some :: WrappedMonad m a -> WrappedMonad m [a] Source # many :: WrappedMonad m a -> WrappedMonad m [a] Source # | |||||
| Monad m => Applicative (WrappedMonad m) | Since: base-2.1 | ||||
Defined in Control.Applicative Methods pure :: a -> WrappedMonad m a Source # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # | |||||
| Monad m => Functor (WrappedMonad m) | Since: base-2.1 | ||||
Defined in Control.Applicative Methods fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # (<$) :: a -> WrappedMonad m b -> WrappedMonad m a Source # | |||||
| Monad m => Monad (WrappedMonad m) | Since: base-4.7.0.0 | ||||
Defined in Control.Applicative Methods (>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b Source # (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # return :: a -> WrappedMonad m a Source # | |||||
| (Typeable m, Typeable a, Data (m a)) => Data (WrappedMonad m a) | Since: base-4.14.0.0 | ||||
Defined in Control.Applicative Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WrappedMonad m a -> c (WrappedMonad m a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (WrappedMonad m a) Source # toConstr :: WrappedMonad m a -> Constr Source # dataTypeOf :: WrappedMonad m a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (WrappedMonad m a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (WrappedMonad m a)) Source # gmapT :: (forall b. Data b => b -> b) -> WrappedMonad m a -> WrappedMonad m a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WrappedMonad m a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WrappedMonad m a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> WrappedMonad m a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> WrappedMonad m a -> u Source # gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> WrappedMonad m a -> m0 (WrappedMonad m a) Source # gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> WrappedMonad m a -> m0 (WrappedMonad m a) Source # gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> WrappedMonad m a -> m0 (WrappedMonad m a) Source # | |||||
| Generic (WrappedMonad m a) | |||||
Defined in Control.Applicative Associated Types
Methods from :: WrappedMonad m a -> Rep (WrappedMonad m a) x Source # to :: Rep (WrappedMonad m a) x -> WrappedMonad m a Source # | |||||
| type Rep1 (WrappedMonad m :: Type -> Type) | Since: base-4.7.0.0 | ||||
Defined in Control.Applicative type Rep1 (WrappedMonad m :: Type -> Type) = D1 ('MetaData "WrappedMonad" "Control.Applicative" "base" 'True) (C1 ('MetaCons "WrapMonad" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonad") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 m))) | |||||
| type Rep (WrappedMonad m a) | Since: base-4.7.0.0 | ||||
Defined in Control.Applicative type Rep (WrappedMonad m a) = D1 ('MetaData "WrappedMonad" "Control.Applicative" "base" 'True) (C1 ('MetaCons "WrapMonad" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonad") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (m a)))) | |||||
This Parser datatype is a specialised parsing monad with error
reporting. Whereas the standard version can be used for arbitrary
token types, this version is specialised to Text input only.
Instances
| Alternative (Parser s) | |
| Applicative (Parser s) | |
Defined in Text.ParserCombinators.Poly.StateText | |
| Functor (Parser s) | |
| Monad (Parser s) | |
| MonadFail (Parser s) | |
| Commitment (Parser s) | |
| PolyParse (Parser s) | |
Defined in Text.ParserCombinators.Poly.StateText | |
A return type like Either, that distinguishes not only between right and wrong answers, but also has commitment, so that a failure cannot be undone. This should only be used for writing very primitive parsers - really it is an internal detail of the library. The z type is the remaining unconsumed input.
reparse :: Text -> Parser s () Source #
Push some tokens back onto the front of the input stream and reparse. This is useful e.g. for recursively expanding macros. When the user-parser recognises a macro use, it can lookup the macro expansion from the parse state, lex it, and then stuff the lexed expansion back down into the parser.
class (Functor p, Monad p, MonadFail p, Applicative p, Alternative p, Commitment p) => PolyParse (p :: Type -> Type) Source #
The PolyParse class is an abstraction gathering all of the common
features that a two-level error-handling parser requires:
the applicative parsing interface, the monadic interface, and commitment.
There are two additional basic combinators that we expect to be implemented
afresh for every concrete type, but which (for technical reasons)
cannot be class methods. They are next and satisfy.
Instances
| PolyParse Parser | |
Defined in Text.ParserCombinators.Poly.ByteString | |
| PolyParse Parser | |
Defined in Text.ParserCombinators.Poly.ByteStringChar | |
| PolyParse Parser | |
Defined in Text.ParserCombinators.Poly.Text | |
| PolyParse (Parser t) | |
Defined in Text.ParserCombinators.Poly.Lazy | |
| PolyParse (Parser t) | |
Defined in Text.ParserCombinators.Poly.Lex | |
| PolyParse (Parser t) | |
Defined in Text.ParserCombinators.Poly.Parser | |
| PolyParse (Parser s) | |
Defined in Text.ParserCombinators.Poly.StateText | |
| PolyParse (Parser s t) | |
Defined in Text.ParserCombinators.Poly.StateLazy | |
| PolyParse (Parser s t) | |
Defined in Text.ParserCombinators.Poly.StateParser | |
class Commitment (p :: Type -> Type) where Source #
The Commitment class is an abstraction over all the current
concrete representations of monadic/applicative parser combinators in this
package. The common feature is two-level error-handling.
Some primitives must be implemented specific to each parser type
(e.g. depending on whether the parser has a running state, or
whether it is lazy). But given those primitives, large numbers of
combinators do not depend any further on the internal structure of
the particular parser.
Methods
Commit is a way of raising the severity of any errors found within its argument. Used in the middle of a parser definition, it means that any operations prior to commitment fail softly, but after commitment, they fail hard.
adjustErr :: p a -> (String -> String) -> p a Source #
p applies the transformation adjustErr ff to any error message
generated in p, having no effect if p succeeds.
oneOf' :: [(String, p a)] -> p a Source #
Parse the first alternative that succeeds, but if none succeed, report only the severe errors, and if none of those, then report all the soft errors.
Instances
| Commitment Parser | |
| Commitment Parser | |
| Commitment Parser | |
| Commitment (Parser t) | |
| Commitment (Parser t) | |
| Commitment (Parser t) | |
| Commitment (Parser s) | |
| Commitment (Parser s t) | |
| Commitment (Parser s t) | |
discard :: PolyParse p => p a -> p b -> p a infixl 3 Source #
x parses both x and y, but discards the result of y.
Rather like discard yconst lifted into parsers.
failBad :: PolyParse p => String -> p a Source #
When a simple fail is not strong enough, use failBad for emphasis. An emphasised (severe) error cannot be overridden by choice operators.
adjustErrBad :: PolyParse p => p a -> (String -> String) -> p a Source #
adjustErrBad is just like adjustErr except it also raises the
severity of the error.
exactly :: PolyParse p => Int -> p a -> p [a] Source #
'exactly n p' parses precisely n items, using the parser p, in sequence.
upto :: PolyParse p => Int -> p a -> p [a] Source #
'upto n p' parses n or fewer items, using the parser p, in sequence.
bracketSep :: PolyParse p => p bra -> p sep -> p ket -> p a -> p [a] Source #
Parse a list of items, discarding the start, end, and separator items.
manyFinally :: PolyParse p => p a -> p z -> p [a] Source #
manyFinally e t parses a possibly-empty sequence of e's,
terminated by a t. The final t is discarded. Any parse failures
could be due either to a badly-formed terminator or a badly-formed
element, so it raises both possible errors.
manyFinally' :: (PolyParse p, Show a) => p a -> p z -> p [a] Source #
manyFinally' is like manyFinally, except when the terminator
parser overlaps with the element parser. In manyFinally e t,
the parser t is tried only when parser e fails, whereas in
manyFinally' e t, the parser t is always tried first, then
parser e only if the terminator is not found. For instance,
manyFinally (accept "01") (accept "0") on input "0101010" returns
["01","01","01"], whereas manyFinally' with the same arguments
and input returns [].
onFail :: Parser s a -> Parser s a -> Parser s a Source #
p means parse p, unless p fails, in which case
parse q instead.
Can be chained together to give multiple attempts to parse something.
(Note that q could itself be a failing parser, e.g. to change the error
message from that defined in p to something different.)
However, a severe failure in p cannot be ignored.onFail q
manySatisfy :: (Char -> Bool) -> Parser s Text Source #
manySatisfy p is a more efficient fused version of many (satisfy p)
many1Satisfy :: (Char -> Bool) -> Parser s Text Source #
many1Satisfy p is a more efficient fused version of many1 (satisfy p)
The ParseDot class.
class ParseDot a where Source #
Minimal complete definition
Methods
parseUnqtList :: Parse [a] Source #
Instances
| ParseDot Version Source # | Ignores |
| ParseDot Word16 Source # | |
| ParseDot Word8 Source # | |
| ParseDot ArrowFill Source # | |
| ParseDot ArrowModifier Source # | |
Defined in Data.GraphViz.Attributes.Arrows Methods parseUnqt :: Parse ArrowModifier Source # parse :: Parse ArrowModifier Source # parseUnqtList :: Parse [ArrowModifier] Source # parseList :: Parse [ArrowModifier] Source # | |
| ParseDot ArrowShape Source # | |
Defined in Data.GraphViz.Attributes.Arrows Methods parseUnqt :: Parse ArrowShape Source # parse :: Parse ArrowShape Source # parseUnqtList :: Parse [ArrowShape] Source # parseList :: Parse [ArrowShape] Source # | |
| ParseDot ArrowSide Source # | |
| ParseDot ArrowType Source # | |
| ParseDot BrewerName Source # | |
Defined in Data.GraphViz.Parsing Methods parseUnqt :: Parse BrewerName Source # parse :: Parse BrewerName Source # parseUnqtList :: Parse [BrewerName] Source # parseList :: Parse [BrewerName] Source # | |
| ParseDot BrewerScheme Source # | |
Defined in Data.GraphViz.Parsing Methods parseUnqt :: Parse BrewerScheme Source # parse :: Parse BrewerScheme Source # parseUnqtList :: Parse [BrewerScheme] Source # parseList :: Parse [BrewerScheme] Source # | |
| ParseDot ColorScheme Source # | |
Defined in Data.GraphViz.Parsing Methods parseUnqt :: Parse ColorScheme Source # parse :: Parse ColorScheme Source # parseUnqtList :: Parse [ColorScheme] Source # parseList :: Parse [ColorScheme] Source # | |
| ParseDot Color Source # | |
| ParseDot WeightedColor Source # | |
Defined in Data.GraphViz.Attributes.Colors Methods parseUnqt :: Parse WeightedColor Source # parse :: Parse WeightedColor Source # parseUnqtList :: Parse [WeightedColor] Source # parseList :: Parse [WeightedColor] Source # | |
| ParseDot SVGColor Source # | |
| ParseDot X11Color Source # | |
| ParseDot Attribute Source # | |
| ParseDot Align Source # | |
| ParseDot Attribute Source # | |
| ParseDot Cell Source # | |
| ParseDot CellFormat Source # | |
Defined in Data.GraphViz.Attributes.HTML Methods parseUnqt :: Parse CellFormat Source # parse :: Parse CellFormat Source # parseUnqtList :: Parse [CellFormat] Source # parseList :: Parse [CellFormat] Source # | |
| ParseDot Format Source # | |
| ParseDot Img Source # | |
| ParseDot Label Source # | |
| ParseDot Row Source # | |
| ParseDot Scale Source # | |
| ParseDot Side Source # | |
| ParseDot Style Source # | |
| ParseDot Table Source # | |
| ParseDot TextItem Source # | |
| ParseDot VAlign Source # | |
| ParseDot CompassPoint Source # | |
Defined in Data.GraphViz.Attributes.Internal Methods parseUnqt :: Parse CompassPoint Source # parse :: Parse CompassPoint Source # parseUnqtList :: Parse [CompassPoint] Source # parseList :: Parse [CompassPoint] Source # | |
| ParseDot PortName Source # | |
| ParseDot PortPos Source # | |
| ParseDot ClusterMode Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse ClusterMode Source # parse :: Parse ClusterMode Source # parseUnqtList :: Parse [ClusterMode] Source # parseList :: Parse [ClusterMode] Source # | |
| ParseDot DEConstraints Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse DEConstraints Source # parse :: Parse DEConstraints Source # parseUnqtList :: Parse [DEConstraints] Source # parseList :: Parse [DEConstraints] Source # | |
| ParseDot DPoint Source # | |
| ParseDot DirType Source # | |
| ParseDot EdgeType Source # | |
| ParseDot FocusType Source # | |
| ParseDot GraphSize Source # | |
| ParseDot Justification Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse Justification Source # parse :: Parse Justification Source # parseUnqtList :: Parse [Justification] Source # parseList :: Parse [Justification] Source # | |
| ParseDot Label Source # | |
| ParseDot LabelScheme Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse LabelScheme Source # parse :: Parse LabelScheme Source # parseUnqtList :: Parse [LabelScheme] Source # parseList :: Parse [LabelScheme] Source # | |
| ParseDot LayerID Source # | |
| ParseDot LayerList Source # | |
| ParseDot LayerListSep Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse LayerListSep Source # parse :: Parse LayerListSep Source # parseUnqtList :: Parse [LayerListSep] Source # parseList :: Parse [LayerListSep] Source # | |
| ParseDot LayerRangeElem Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse LayerRangeElem Source # parse :: Parse LayerRangeElem Source # parseUnqtList :: Parse [LayerRangeElem] Source # parseList :: Parse [LayerRangeElem] Source # | |
| ParseDot LayerSep Source # | |
| ParseDot ModeType Source # | |
| ParseDot Model Source # | |
| ParseDot NodeSize Source # | |
| ParseDot Normalized Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse Normalized Source # parse :: Parse Normalized Source # parseUnqtList :: Parse [Normalized] Source # parseList :: Parse [Normalized] Source # | |
| ParseDot Number Source # | |
| ParseDot Order Source # | |
| ParseDot OutputMode Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse OutputMode Source # parse :: Parse OutputMode Source # parseUnqtList :: Parse [OutputMode] Source # parseList :: Parse [OutputMode] Source # | |
| ParseDot Overlap Source # | Note that |
| ParseDot Pack Source # | |
| ParseDot PackMode Source # | |
| ParseDot PageDir Source # | |
| ParseDot Paths Source # | |
| ParseDot Point Source # | |
| ParseDot Pos Source # | |
| ParseDot QuadType Source # | |
| ParseDot RankDir Source # | |
| ParseDot RankType Source # | |
| ParseDot Ratios Source # | |
| ParseDot RecordField Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse RecordField Source # parse :: Parse RecordField Source # parseUnqtList :: Parse [RecordField] Source # parseList :: Parse [RecordField] Source # | |
| ParseDot Rect Source # | |
| ParseDot Root Source # | |
| ParseDot STStyle Source # | |
| ParseDot SVGFontNames Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse SVGFontNames Source # parse :: Parse SVGFontNames Source # parseUnqtList :: Parse [SVGFontNames] Source # parseList :: Parse [SVGFontNames] Source # | |
| ParseDot ScaleType Source # | |
| ParseDot Shape Source # | |
| ParseDot SmoothType Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse SmoothType Source # parse :: Parse SmoothType Source # parseUnqtList :: Parse [SmoothType] Source # parseList :: Parse [SmoothType] Source # | |
| ParseDot Spline Source # | |
| ParseDot StartType Source # | |
| ParseDot StyleItem Source # | |
| ParseDot StyleName Source # | |
| ParseDot VerticalPlacement Source # | |
Defined in Data.GraphViz.Attributes.Values Methods parseUnqt :: Parse VerticalPlacement Source # parse :: Parse VerticalPlacement Source # | |
| ParseDot ViewPort Source # | |
| ParseDot GraphvizCommand Source # | |
Defined in Data.GraphViz.Commands.Available Methods parseUnqt :: Parse GraphvizCommand Source # parse :: Parse GraphvizCommand Source # parseUnqtList :: Parse [GraphvizCommand] Source # parseList :: Parse [GraphvizCommand] Source # | |
| ParseDot GlobalAttributes Source # | |
Defined in Data.GraphViz.Types.Internal.Common Methods parseUnqt :: Parse GlobalAttributes Source # parse :: Parse GlobalAttributes Source # | |
| ParseDot GraphID Source # | |
| ParseDot Text Source # | |
| ParseDot Text Source # | |
| ParseDot Integer Source # | |
| ParseDot Bool Source # | |
| ParseDot Char Source # | |
| ParseDot Double Source # | |
| ParseDot Int Source # | |
| ParseDot n => ParseDot (DotGraph n) Source # | |
| ParseDot n => ParseDot (DotStatements n) Source # | |
Defined in Data.GraphViz.Types.Canonical Methods parseUnqt :: Parse (DotStatements n) Source # parse :: Parse (DotStatements n) Source # parseUnqtList :: Parse [DotStatements n] Source # parseList :: Parse [DotStatements n] Source # | |
| ParseDot n => ParseDot (DotSubGraph n) Source # | |
Defined in Data.GraphViz.Types.Canonical Methods parseUnqt :: Parse (DotSubGraph n) Source # parse :: Parse (DotSubGraph n) Source # parseUnqtList :: Parse [DotSubGraph n] Source # parseList :: Parse [DotSubGraph n] Source # | |
| ParseDot n => ParseDot (DotGraph n) Source # | |
| ParseDot n => ParseDot (DotStatement n) Source # | |
Defined in Data.GraphViz.Types.Generalised Methods parseUnqt :: Parse (DotStatement n) Source # parse :: Parse (DotStatement n) Source # parseUnqtList :: Parse [DotStatement n] Source # parseList :: Parse [DotStatement n] Source # | |
| ParseDot n => ParseDot (DotSubGraph n) Source # | |
Defined in Data.GraphViz.Types.Generalised Methods parseUnqt :: Parse (DotSubGraph n) Source # parse :: Parse (DotSubGraph n) Source # parseUnqtList :: Parse [DotSubGraph n] Source # parseList :: Parse [DotSubGraph n] Source # | |
| (Ord n, ParseDot n) => ParseDot (DotGraph n) Source # | Uses the ParseDot instance for generalised |
| ParseDot n => ParseDot (DotEdge n) Source # | |
| ParseDot n => ParseDot (DotNode n) Source # | |
| ParseDot a => ParseDot [a] Source # | |
parseIt :: ParseDot a => Text -> (a, Text) Source #
Parse the required value, returning also the rest of the input
Text that hasn't been parsed (for debugging purposes).
parseIt' :: ParseDot a => Text -> a Source #
Parse the required value with the assumption that it will parse
all of the input Text.
runParser' :: Parse a -> Text -> a Source #
runParserWith :: (GraphvizState -> GraphvizState) -> Parse a -> Text -> (Either String a, Text) Source #
parseLiberally :: GraphvizState -> GraphvizState Source #
checkValidParse :: Either String a -> a Source #
If unable to parse Dot code properly, throw a
GraphvizException.
checkValidParseWithRest :: (Either String a, Text) -> a Source #
If unable to parse Dot code properly, throw a
GraphvizException, with the error containing the remaining
unparsed code..
Convenience parsing combinators.
ignoreSep :: (a -> b -> c) -> Parse a -> Parse sep -> Parse b -> Parse c Source #
The opposite of bracket.
stringBlock :: Parse Text Source #
isNumString :: Bool -> Text -> Bool Source #
Determine if this String represents a number. Boolean parameter determines if exponents are considered part of numbers for this.
isIntString :: Text -> Bool Source #
quotedString :: Parse Text Source #
Used when quotes are explicitly required;
parseAndSpace :: Parse a -> Parse a Source #
character :: Char -> Parse Char Source #
Assumes that any letter is ASCII for case-insensitive comparisons.
parseStrictFloat :: Bool -> Parse Double Source #
Parse a floating point number that actually contains decimals. Bool flag indicates whether values that need to be quoted are parsed.
whitespace1 :: Parse () Source #
Parses at least one whitespace character.
whitespace :: Parse () Source #
Parses zero or more whitespace characters.
wrapWhitespace :: Parse a -> Parse a Source #
Parse and discard optional surrounding whitespace.
optionalQuotedString :: String -> Parse () Source #
optionalQuoted :: Parse a -> Parse a Source #
quotedParse :: Parse a -> Parse a Source #
Consume all whitespace and newlines until a line with non-whitespace is reached. The whitespace on that line is not consumed.
parseComma :: Parse () Source #
tryParseList :: ParseDot a => Parse [a] Source #
Try to parse a list of the specified type; returns an empty list if parsing fails.
tryParseList' :: Parse [a] -> Parse [a] Source #
Return an empty list if parsing a list fails.
consumeLine :: Parse Text Source #
Parses and returns all characters up till the end of the line, but does not touch the newline characters.
stringReps :: a -> [String] -> Parse a Source #
stringValue :: [(String, a)] -> Parse a Source #
parseAngled :: Parse a -> Parse a Source #
parseBraced :: Parse a -> Parse a Source #
parseColorScheme :: Bool -> Parse ColorScheme Source #