runSettingsParser Run runParser on your Settings' type's settingsParser.
This is most likely the function you want to be using.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Moduleopt-env-conf-0.11.0.0Haskell2010
runSettingsParser Run runParser on your Settings' type's settingsParser.
This is most likely the function you want to be using.
A class of types that have a canonical settings parser.
There are no laws. The closest rule to a law is that a user of an instance should not be surprised by its behaviour.
settingsParser :: Parser aA Parser structure
A Parser a value represents each of these all at once:
A way to run it to parse an a
A way to document it in various ways
A way to run it to perform shell completion
The basic building block of a Parser is a setting. settings represent individual settings that you can then compose into larger parsers.
Much of the way you compose parsers happens via its type class instances. In particular:
<*> from Applicative to "and" Parsers
<|> from Alternative to "or" Parsers
optional from Alternative to optionally run a parser
many and some from Alternative to run the same parser multiple times.
You can run a parser with runParser, or give your type an instance of
HasParser and run the parser with runSettingsParser.
Functor ParserDefined in opt-env-conf-0.11.0.0 · OptEnvConf.ParserApplicative ParserDefined in opt-env-conf-0.11.0.0 · OptEnvConf.ParserAlternative ParserDefined in opt-env-conf-0.11.0.0 · OptEnvConf.ParserSelective ParserDefined in opt-env-conf-0.11.0.0 · OptEnvConf.ParserrunParser Run a parser
This function with exit on:
Parse failure: show a nice error message.
-h|--help: Show help text
--version: Show version information
--render-man-page: Render a man page
--bash-completion-script: Render a bash completion script
--zsh-completion-script: Render a zsh completion script
--fish-completion-script: Render a fish completion script
query-opt-env-conf-completion: Perform a completion query
This gets the arguments and environment variables from the current process.
settings are the building blocks of Parsers.
setting lets you put together different builders to define what to parse.
Here are some common examples:
Argument
setting
[ help "Document your argument"
, reader str -- The argument is a string
, argument
] :: Parser String
Switch
setting
[ help "Document your switch"
, switch True -- The value of the switch when activated
, long foo -- "--foo"
, short f -- "-f"
, value False -- The default value of the switch
] :: Parser Bool
Option
setting
[ help "Document your option"
, reader str -- The argument is a string
, long foo -- "--foo"
, short f -- "-f"
, option
] :: Parser String
Environment Variable
setting
[ help "Document your environment variable"
, reader str -- The argument is a string
, env FOO_BAR
] :: Parser String
Configuration Value
setting
[ help "Document your configuration value"
, conf "foo-bar"
] :: Parser String
Some combination
setting
[ help "Document your configuration value"
, conf "foo-bar"
] :: Parser String
Note that parsing is always tried in this order when using a combined setting:
Argument
Switch
Option
Environment variable
Configuration value
(Hence the name of the package.)
Document a setting
Multiple helps concatenate help on new lines.
Declare how to parse an argument, option, or environment variable.
Like env but ignores any subEnv, subEnv_, or subAll.
Try to parse a configuration value at the given key.
Multiple confs will be tried in order.
Like confWith but allows interpreting Null as a value other than "Not found".
Like conf but ignores any subConf, subConf_, or subAll.
Like confWith but ignores any subConf, subConf_, or subAll.
Like confWith' but ignores any subConf, subConf_, or subAll.
Set the default value
Multiple values override eachother.
API Note: default is not a valid identifier in Haskell.
I'd also have preferred default instead.
Set the setting to tab-complete with the given completer
Multiple completers are redundant.
command :: HasCallStack=> StringName
-> StringDocumentation
-> Parser aParser
-> CommandsBuilder aDeclare a single command with a name, documentation and parser
One or none.
It is useful for modelling any computation that is allowed to fail.
Using the Alternative instance of Control.Monad.Except, the following functions:
import Control.Monad.ExceptcanFail = throwError "it failed" :: Except String Intfinal = 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
An infix synonym for fmap.
The name of this operator is an allusion to Prelude.$.
Note the similarities between their types:
($) :: (a -> b) -> a -> b
(<$>) :: Functor f => (a -> b) -> f a -> f bWhereas Prelude.$ is function application, <$> is function
application lifted over a Functor.
Convert from a Maybe Int to a Maybe
String using show:
show <$> NothingNothing
show <$> Just 3Just "3"
Convert from an Either Int Int to an
Either Int String 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)
Sequential application.
A few functors support an implementation of <*> that is more efficient than the default one.
Used in combination with , (Data.Functor.<$>) can be used to build a record.(<*>)
data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}produceFoo :: Applicative f => f FooproduceBar :: Applicative f => f BarproduceBaz :: Applicative f => f Baz
mkState :: Applicative f => f MyStatemkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
An associative binary operation
Zero or more.
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.
One or more.
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.
Helper function for calling subConfig with toConfigCase.
subConfig_ s = subConfig (toConfigCase s)Helper function for calling subArgs_, subEnv_ and subConfig_ with the same prefix.
subAll = subArgs_ prefix . subEnv_ prefix . subConfig_ prefixUse the settingsParser of a given type, but prefixed with a subAll and allOrNothing.
subSettings prefix = allOrNothing $ subAll prefix settingsParserParse either all or none of the parser below.
If you don't use this function, and only some of the settings below are defined, this parser will fail and the next alternative will be tried. If you do use this function, this parser will error unforgivably if at least one, but not all, of the settings below are defined.
If each setting has a corresponding forgivable error, consider this forgivable. Consider all other forgivable errors unforgivable
For example, the following will parser will fail intsead of succeed when given the arguments below:
( choice
[ allOrNothing $
(,)
<$> setting [option, long "foo", reader auto, help "This one will exist", metavar "CHAR"]
<*> setting [option, long "bar", reader auto, help "This one will not exist", metavar "CHAR"],
pure ('a', 'b')
]
)["--foo", "'a'"]Turn a string into arg case for option names
Example: this-is-arg-case
Turn a string into env case for environment variable names
Example: THIS_IS_ENV_CASE
Turn a string into config case for configuration value names
Example: this-is-config-case
Like some but with a more accurate type
Like checkMapEither but without changing the type
Like checkMapMaybe but without changing the type
Check a Parser after the fact, purely.
Check a Parser after the fact, allowing IO.
Like checkMapEither but without a helpful error message.
Prefer checkMapEither.
Like checkMapEither, but allow trying the other side of any alternative if the result is Nothing.
Like checkMapIO, but allow trying the other side of any alternative if the result is Nothing. TODO add a SRCLoc here
Like checkMapMaybe, but allow trying the other side of any alternative if the result is Nothing.
Like checkMapEither but without a helpful error message.
Prefer checkMapEither.
Apply a computation to the result of a parser
This is intended for use-cases like resolving a file to an absolute path. It is morally ok for read-only IO actions but you will have a bad time if the action is not read-only.
Try a list of parsers in order
Give a parser a default value.
This is morally equal to (| pure a) but will give
you better documentation of the default value in many
cases.
This does nothing if the parser already has a default value.
Like withDefault but lets you specfiy how to show the default value yourself.
Load a configuration value and use it for the given parser
Load a YAML config file and use it for the given parser
Load the Yaml config in the first of the filepaths that points to something that exists.
Combine all Yaml config files that exist into a single combined config object.
Load config.yaml from the given XDG configuration subdirectory
Load a config file that is reconfigurable with an option and environment
variable but config.yaml in the local working directory by default.
Use the given Parser for deciding which configuration file to load, but only if configuredConfigFile fails to define it first.
Define a setting for a Bool with a given default value.
If you pass in long values, it will have --enable-foobar and --disable-foobar switches.
If you pass in env values, it will read those environment variables too.
If you pass in conf values, it will read those configuration values too.
If you pass in a value value, it will use that as the default value.
Define a setting for a Bool with a given default value.
If you pass in long values, it will have --foobar and --no-foobar switches.
If you pass in env values, it will read those environment variables too.
If you pass in conf values, it will read those configuration values too.
If you pass in a value value, it will use that as the default value.
Read a text file but strip whitespace so it can be edited with an editor that messes with line endings.
Load a secret from a text file, with readSecretTextFile
Load a secret from a text file, with readSecretTextFile, or specify it directly
Always return True
exists = Reader $ const $ pure TrueLike commaSeparated but uses a list type.
Note that this will never parse the empty list, so prefer commaSeparated if you want a more accurately typed function.
Turn a reader into one that parses comma separated values with that reader.
Like commaSeparated but uses a set type.
Note that this will never parse the empty list, so prefer commaSeparated if you want a more accurately typed function.
Note also that this function throws away any ordering information and ignores any duplicate values.
module OptEnvConf.Casing
module OptEnvConf.Doc
module OptEnvConf.Nix
module OptEnvConf.Parser
module OptEnvConf.Completer
module OptEnvConf.Reader
module OptEnvConf.Run
module OptEnvConf.Setting
One or none.
It is useful for modelling any computation that is allowed to fail.
Using the Alternative instance of Control.Monad.Except, the following functions:
import Control.Monad.ExceptcanFail = throwError "it failed" :: Except String Intfinal = 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
An infix synonym for fmap.
The name of this operator is an allusion to Prelude.$.
Note the similarities between their types:
($) :: (a -> b) -> a -> b
(<$>) :: Functor f => (a -> b) -> f a -> f bWhereas Prelude.$ is function application, <$> is function
application lifted over a Functor.
Convert from a Maybe Int to a Maybe
String using show:
show <$> NothingNothing
show <$> Just 3Just "3"
Convert from an Either Int Int to an
Either Int String 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)
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:
(<*>) = liftA2 idliftA2 f x y = f Prelude.<$> x <*> yFurther, any definition must satisfy the following:
pure id <*> v = vpure (.) <*> u <*> v <*> w = u <*> (v <*> w)pure f <*> pure x = pure (f x)u <*> pure y = pure ($ y) <*> uThe 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 yit follows from the above that
liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g vIf f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
pure :: a -> f aLift a value into the Structure.
pure 1 :: Maybe IntJust 1
pure 'z' :: [Char]"z"
pure (pure ":D") :: Maybe [String]Just [":D"]
(<*>) :: f (a -> b) -> f a -> f binfixl 4Sequential application.
A few functors support an implementation of <*> that is more efficient than the default one.
Used in combination with , (Data.Functor.<$>) can be used to build a record.(<*>)
data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}produceFoo :: Applicative f => f FooproduceBar :: Applicative f => f BarproduceBaz :: Applicative f => f Baz
mkState :: Applicative f => f MyStatemkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
liftA2 :: (a -> b -> c) -> f a -> f b -> f cLift 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.
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 binfixl 4Sequence actions, discarding the value of the first argument.
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.Charimport GHC.Internal.Text.ParserCombinators.ReadPlet p = string "my name is " *> munch1 isAlpha <* eofreadP_to_S p "my name is Simon"[("Simon","")]
(<*) :: f a -> f b -> f ainfixl 4Sequence actions, discarding the value of the second argument.
Applicative GenDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.GenApplicative RoseDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.PropertyApplicative IResultDefined in aeson-2.2.3.0 · Data.Aeson.Types.InternalApplicative ParserDefined in aeson-2.2.3.0 · Data.Aeson.Types.InternalApplicative ResultDefined in aeson-2.2.3.0 · Data.Aeson.Types.InternalApplicative ResultDefined in autodocodec-0.5.0.0 · Autodocodec.CodecApplicative ComplexDefined in base-4.20.2.0 · Data.ComplexApplicative FirstDefined in base-4.20.2.0 · Data.SemigroupApplicative LastDefined in base-4.20.2.0 · Data.SemigroupApplicative MaxDefined in base-4.20.2.0 · Data.SemigroupApplicative MinDefined in base-4.20.2.0 · Data.SemigroupApplicative GetDefined in binary-0.8.9.3 · Data.Binary.Get.InternalApplicative PutMDefined in binary-0.8.9.3 · Data.Binary.PutApplicative PutDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.InternalApplicative SeqDefined in containers-0.7 · Data.Sequence.InternalApplicative TreeDefined in containers-0.7 · Data.TreeApplicative DNonEmptyDefined in dlist-1.0 · Data.DList.DNonEmpty.InternalApplicative DListDefined in dlist-1.0 · Data.DList.InternalApplicative NonEmptyDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncApplicative IdentityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityApplicative FirstDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidApplicative LastDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidApplicative DownDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdApplicative DualDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative ProductDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative SumDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListf <$> ZipList xs1 <*> ... <*> ZipList xsN
= ZipList (zipWithN f xs1 ... xsN)where zipWithN refers to the zipWith function of the appropriate arity
(zipWith, zipWith3, zipWith4, ...). For example:
(\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"]}Applicative NoIODefined in ghc-internal-9.1003.0 · GHC.Internal.GHCiApplicative Par1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPApplicative ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPApplicative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecApplicative SoloDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative IODefined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative ParserDefined in opt-env-conf-0.11.0.0 · OptEnvConf.ParserApplicative ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayApplicative SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayApplicative AcquireDefined in resourcet-1.3.0 · Data.Acquire.InternalApplicative STMDefined in stm-2.5.3.1 · Control.Sequential.STMApplicative PprMDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLibApplicative QDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxApplicative CapabilityDefined in terminfo-0.4.1.7 · System.Console.Terminfo.BaseApplicative VectorDefined in vector-0.13.2.0 · Data.VectorApplicative IdDefined in vector-0.13.2.0 · Data.Vector.Fusion.UtilApplicative VectorDefined in vector-0.13.2.0 · Data.Vector.StrictApplicative BoxDefined in vector-stream-0.1.0.1 · Data.Stream.MonadicApplicative YamlParserDefined in yaml-0.11.11.2 · Data.Yaml.ParserApplicative []Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyApplicative U1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative (PropertyM m)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.MonadicApplicative (Parser i)Defined in attoparsec-0.14.4 · Data.Attoparsec.Internal.TypesApplicative (ObjectCodec input)Defined in autodocodec-0.5.0.0 · Autodocodec.CodecApplicative (SetM s)Defined in containers-0.7 · Data.GraphApplicative (State s)Defined in containers-0.7 · Utils.Containers.Internal.StateApplicative (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Monad.ST.Lazy.ImpApplicative (Either e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.EitherApplicative (StateL s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsApplicative (StateR s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsApplicative (ST s)Defined in ghc-internal-9.1003.0 · GHC.Internal.STApplicative (Validation e)Defined in opt-env-conf-0.11.0.0 · OptEnvConf.ValidationApplicative (Select f)Defined in selective-0.7.0.1 · Control.Selective.FreeApplicative (Select f)Defined in selective-0.7.0.1 · Control.Selective.Rigid.FreerApplicative (IParser t)Defined in text-2.1.3 · Data.Text.Internal.ReadApplicative f => Applicative (WrappedPoly f)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableApplicative f => Applicative (SelectA f)Defined in selective-0.7.0.1 · Control.SelectiveApplicative f => Applicative (SelectM f)Defined in selective-0.7.0.1 · Control.SelectiveApplicative f => Applicative (WrappedApplicative f)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassApplicative f => Applicative (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftA combination is Pure only if both parts are.
Applicative f => Applicative (WrappedFoldable f)Defined in witherable-0.5 · WitherableApplicative m => Applicative (ResourceT m)Defined in resourcet-1.3.0 · Control.Monad.Trans.Resource.InternalApplicative m => Applicative (QuoteToQuasi m)Defined in th-compat-0.1.6 · Language.Haskell.TH.Syntax.CompatFunctor f => Applicative (Select f)Defined in selective-0.7.0.1 · Control.Selective.Rigid.FreeMonad f => Applicative (ListT f)Defined in opt-env-conf-0.11.0.0 · OptEnvConf.NonDetMonad m => Applicative (ZeptoT m)Defined in attoparsec-0.14.4 · Data.Attoparsec.ZeptoMonad m => Applicative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Applicative (ZipSource m)Defined in conduit-1.3.6.1 · Data.Conduit.Internal.ConduitMonad m => Applicative (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.PureMonoid a => Applicative (Tuple2 a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid m => Applicative (Over m)Defined in selective-0.7.0.1 · Control.SelectiveMonoid m => Applicative (Under m)Defined in selective-0.7.0.1 · Control.SelectiveMonoid m => Applicative (Over m)Defined in selective-0.7.0.1 · Control.Selective.MultiMonoid m => Applicative (Under m)Defined in selective-0.7.0.1 · Control.Selective.MultiSemigroup a => Applicative (These a)Defined in strict-0.5.1 · Data.Strict.TheseSemigroup a => Applicative (These a)Defined in these-1.2.1 · Data.TheseSemigroup e => Applicative (Validation e)Defined in selective-0.7.0.1 · Control.SelectiveArrow a => Applicative (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowRepeat f => Applicative (Zippy f)Defined in semialign-1.3.1 · Data.ZipApply f => Applicative (MaybeApply f)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.Class(Functor m, Monad m) => Applicative (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeBiapplicative p => Applicative (Fix p)Defined in bifunctors-5.6.2 · Data.Bifunctor.FixBiapplicative p => Applicative (Join p)Defined in bifunctors-5.6.2 · Data.Bifunctor.JoinApplicative (Mag a b)Defined in bifunctors-5.6.2 · Data.BiapplicativeApplicative (Tagged s)Defined in tagged-0.8.9 · Data.TaggedApplicative (bi a) => Applicative (Biap bi a)Defined in bifunctors-5.6.2 · Data.Bifunctor.BiapApplicative (t m) => Applicative (LiftingAccum t m)Defined in mtl-2.3.1 · Control.Monad.AccumApplicative (t m) => Applicative (LiftingSelect t m)Defined in mtl-2.3.1 · Control.Monad.SelectApplicative f => Applicative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidApplicative f => Applicative (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalApplicative f => Applicative (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative f => Applicative (Indexing f)Defined in indexed-traversable-0.1.4 · WithIndexApplicative f => Applicative (Static f a)Defined in semigroupoids-6.0.1 · Data.Semigroupoid.StaticApplicative f => Applicative (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsApply f-actions in the reverse order.
Applicative f => Applicative (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseDerived instance.
Applicative m => Applicative (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowApplicative m => Applicative (ValidationT e m)Defined in opt-env-conf-0.11.0.0 · OptEnvConf.ValidationApplicative m => Applicative (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityApplicative m => Applicative (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ReaderApplicative w => Applicative (TracedT m w)Defined in comonad-5.0.9 · Control.Comonad.Trans.TracedMonad m => Applicative (ZipSink i m)Defined in conduit-1.3.6.1 · Data.Conduit.Internal.ConduitMonad m => Applicative (StateT s m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsMonoid a => Applicative (Constant a)Defined in transformers-0.6.1.1 · Data.Functor.ConstantMonoid m => Applicative (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstArrow a => Applicative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.ApplicativeSelective f => Applicative (ComposeEither f e)Defined in selective-0.7.0.1 · Control.SelectiveSelective f => Applicative (ExceptT e f)Defined in selective-0.7.0.1 · Control.Selective.Trans.Except(Applicative f, Applicative g) => Applicative (ComposeTraversable f g)Defined in selective-0.7.0.1 · Control.Selective(Applicative f, Monad f) => Applicative (WhenMissing f x)Defined in containers-0.7 · Data.IntMap.InternalEquivalent to ReaderT k (ReaderT x (MaybeT f)).
(Applicative w, Monoid s) => Applicative (StoreT s w)Defined in comonad-5.0.9 · Control.Comonad.Trans.Store(Functor m, Monad m) => Applicative (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Functor m, Monad m) => Applicative (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select(Functor m, Monad m) => Applicative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy(Functor m, Monad m) => Applicative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, Monad m) => Applicative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS(Monoid a, Monoid b) => Applicative (Tuple3 a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base(Monoid e, Applicative m) => Applicative (EnvT e m)Defined in comonad-5.0.9 · Control.Comonad.Trans.Env(Monoid w, Applicative m) => Applicative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Monoid w, Applicative m) => Applicative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict(Monoid w, Functor m, Monad m) => Applicative (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum(Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsApplicative (Cokleisli w a)Defined in comonad-5.0.9 · Control.ComonadApplicative (ConduitT i o m)Defined in conduit-1.3.6.1 · Data.Conduit.Internal.ConduitApplicative (ParsecT s u m)Defined in parsec-3.1.18.0 · Text.Parsec.PrimApplicative (ContT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ContApplicative ((->) r)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonad m => Applicative (ZipConduit i o m)Defined in conduit-1.3.6.1 · Data.Conduit.Internal.ConduitMonoid c => Applicative (K1 i c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Applicative f, Applicative g) => Applicative (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Applicative f, Applicative g) => Applicative (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Applicative f, Monad f) => Applicative (WhenMissing f k x)Defined in containers-0.7 · Data.Map.InternalEquivalent to ReaderT k (ReaderT x (MaybeT f)) .
(Monad f, Applicative f) => Applicative (WhenMatched f x y)Defined in containers-0.7 · Data.IntMap.InternalEquivalent to ReaderT Key (ReaderT x (ReaderT y (MaybeT f)))
(Monoid a, Monoid b, Monoid c) => Applicative (Tuple4 a b c)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseApplicative f => Applicative (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Applicative f, Applicative g) => Applicative (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Applicative f, Applicative g) => Applicative (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Functor m, Monad m) => Applicative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS(Monad f, Applicative f) => Applicative (WhenMatched f k x y)Defined in containers-0.7 · Data.Map.InternalEquivalent to ReaderT k (ReaderT x (ReaderT y (MaybeT f)))
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.StrictMonad m => Applicative (Pipe l i o u m)Defined in conduit-1.3.6.1 · Data.Conduit.Internal.PipeA monoid on applicative functors.
If defined, some and many should be the least solutions of the equations:
Nothing <|> Just 42Just 42
[1, 2] <|> [3, 4][1,2,3,4]
empty <|> print (2^15)32768
empty :: f aThe identity of <|>
empty <|> a == a
a <|> empty == a(<|>) :: f a -> f a -> f ainfixl 3An associative binary operation
some :: f a -> f [a]One or more.
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.
many :: f a -> f [a]Zero or more.
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.
Alternative IResultDefined in aeson-2.2.3.0 · Data.Aeson.Types.InternalAlternative ParserDefined in aeson-2.2.3.0 · Data.Aeson.Types.InternalAlternative ResultDefined in aeson-2.2.3.0 · Data.Aeson.Types.InternalAlternative GetDefined in binary-0.8.9.3 · Data.Binary.Get.InternalAlternative SeqDefined in containers-0.7 · Data.Sequence.InternalAlternative DListDefined in dlist-1.0 · Data.DList.InternalAlternative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncAlternative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListAlternative MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPAlternative ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPAlternative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecAlternative IODefined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative ParserDefined in opt-env-conf-0.11.0.0 · OptEnvConf.ParserAlternative ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayAlternative SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayAlternative CapabilityDefined in terminfo-0.4.1.7 · System.Console.Terminfo.BaseAlternative VectorDefined in vector-0.13.2.0 · Data.VectorAlternative VectorDefined in vector-0.13.2.0 · Data.Vector.StrictAlternative YamlParserDefined in yaml-0.11.11.2 · Data.Yaml.ParserAlternative []Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseCombines lists by concatenation, starting from the empty list.
Alternative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyAlternative U1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative (Parser i)Defined in attoparsec-0.14.4 · Data.Attoparsec.Internal.TypesAlternative f => Alternative (WrappedApplicative f)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassAlternative f => Alternative (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftA combination is Pure only either part is.
Alternative f => Alternative (WrappedFoldable f)Defined in witherable-0.5 · WitherableAlternative m => Alternative (ResourceT m)Defined in resourcet-1.3.0 · Control.Monad.Trans.Resource.InternalSince 1.1.5
Monad f => Alternative (ListT f)Defined in opt-env-conf-0.11.0.0 · OptEnvConf.NonDetMonad m => Alternative (ZeptoT m)Defined in attoparsec-0.14.4 · Data.Attoparsec.ZeptoMonad m => Alternative (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.PureMonadPlus m => Alternative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeArrowPlus a => Alternative (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow(Functor m, Monad m) => Alternative (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeAlternative (bi a) => Alternative (Biap bi a)Defined in bifunctors-5.6.2 · Data.Bifunctor.BiapAlternative f => Alternative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidAlternative f => Alternative (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalAlternative f => Alternative (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsTry alternatives in the same order as f.
Alternative f => Alternative (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseDerived instance.
Alternative m => Alternative (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowAlternative m => Alternative (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityAlternative m => Alternative (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Reader(Functor m, Monad m, Monoid e) => Alternative (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Functor m, MonadPlus m) => Alternative (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, MonadPlus m) => Alternative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS(Monoid w, Alternative m) => Alternative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Monoid w, Alternative m) => Alternative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict(Monoid w, Functor m, MonadPlus m) => Alternative (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(Generic1 f, Alternative (Rep1 f)) => Alternative (Generically1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Selective f, Monoid e) => Alternative (ComposeEither f e)Defined in selective-0.7.0.1 · Control.Selective(Selective f, Monoid e) => Alternative (ExceptT e f)Defined in selective-0.7.0.1 · Control.Selective.Trans.ExceptAlternative (ParsecT s u m)Defined in parsec-3.1.18.0 · Text.Parsec.Prim(Alternative f, Alternative g) => Alternative (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Alternative f, Alternative g) => Alternative (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Alternative f, Applicative g) => Alternative (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Alternative f, Applicative g) => Alternative (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS(Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy(Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.StrictReplace 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.
Perform a computation with Maybe and replace the result with a constant value if it is Just:
'a' <$ Just 2Just 'a''a' <$ NothingNothing
The Const functor.
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]
Semigroupoid ConstDefined in semigroupoids-6.0.1 · Data.SemigroupoidGeneric1 (Const a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFoldableWithIndex Void (Const e)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Void (Const e)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Void (Const e)Defined in indexed-traversable-0.1.4 · WithIndexUnbox a => Vector Vector (Const a b)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseUnbox a => MVector MVector (Const a b)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseBifoldable ConstDefined in base-4.20.2.0 · Data.BifoldableBifoldable1 ConstDefined in base-4.20.2.0 · Data.Bifoldable1Bifunctor ConstDefined in base-4.20.2.0 · Data.BifunctorBitraversable ConstDefined in base-4.20.2.0 · Data.BitraversableEq2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesOrd2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesRead2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesShow2 ConstDefined in base-4.20.2.0 · Data.Functor.ClassesNFData2 ConstDefined in deepseq-1.5.0.0 · Control.DeepSeqArbitrary2 ConstDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryHashable2 ConstDefined in hashable-1.4.7.0 · Data.Hashable.ClassAssoc ConstDefined in assoc-1.1.1 · Data.Bifunctor.AssocBiapplicative ConstDefined in bifunctors-5.6.2 · Data.BiapplicativeBiapply ConstDefined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassBitraversable1 ConstDefined in semigroupoids-6.0.1 · Data.Semigroup.Traversable.ClassFromJSON2 ConstDefined in aeson-2.2.3.0 · Data.Aeson.Types.FromJSONToJSON2 ConstDefined in aeson-2.2.3.0 · Data.Aeson.Types.ToJSONFunctor (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstMonoid m => Applicative (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFoldable (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstTraversable (Const m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.TraversableEq a => Eq1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesOrd a => Ord1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesRead a => Read1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesShow a => Show1 (Const a)Defined in base-4.20.2.0 · Data.Functor.ClassesContravariant (Const a)Defined in base-4.20.2.0 · Data.Functor.ContravariantNFData a => NFData1 (Const a)Defined in deepseq-1.5.0.0 · Control.DeepSeqArbitrary a => Arbitrary1 (Const a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryHashable a => Hashable1 (Const a)Defined in hashable-1.4.7.0 · Data.Hashable.ClassMonoid m => Divisible (Const m)Defined in contravariant-1.5.5 · Data.Functor.Contravariant.DivisibleSemigroup m => Apply (Const m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassA Const m is not Applicative unless its m is a Monoid, but it is an instance of Apply
Semigroup m => Divise (Const m)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.DiviseFilterable (Const r)Defined in witherable-0.5 · WitherableWitherable (Const r)Defined in witherable-0.5 · WitherableFromJSON a => FromJSON1 (Const a)Defined in aeson-2.2.3.0 · Data.Aeson.Types.FromJSONToJSON a => ToJSON1 (Const a)Defined in aeson-2.2.3.0 · Data.Aeson.Types.ToJSONBounded a => Bounded (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstEnum a => Enum (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstEq a => Eq (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFloating a => Floating (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFractional a => Fractional (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstIntegral a => Integral (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const(Typeable k, Data a, Typeable b) => Data (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataNum a => Num (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstOrd a => Ord (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRead a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstReal a => Real (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRealFloat a => RealFloat (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRealFrac a => RealFrac (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstShow a => Show (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstIx a => Ix (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstIsString a => IsString (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.StringGeneric (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstSemigroup a => Semigroup (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstMonoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstBits a => Bits (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFiniteBits a => FiniteBits (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstStorable a => Storable (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstNFData a => NFData (Const a b)Defined in deepseq-1.5.0.0 · Control.DeepSeqArbitrary a => Arbitrary (Const a b)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryCoArbitrary a => CoArbitrary (Const a b)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryFunction a => Function (Const a b)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.FunctionHashable a => Hashable (Const a b)Defined in hashable-1.4.7.0 · Data.Hashable.ClassPrim a => Prim (Const a b)Defined in primitive-0.9.1.0 · Data.Primitive.TypesUnbox a => Unbox (Const a b)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.BaseFromJSON a => FromJSON (Const a b)Defined in aeson-2.2.3.0 · Data.Aeson.Types.FromJSON(FromJSON a, FromJSONKey a) => FromJSONKey (Const a b)Defined in aeson-2.2.3.0 · Data.Aeson.Types.FromJSONToJSON a => ToJSON (Const a b)Defined in aeson-2.2.3.0 · Data.Aeson.Types.ToJSON(ToJSON a, ToJSONKey a) => ToJSONKey (Const a b)Defined in aeson-2.2.3.0 · Data.Aeson.Types.ToJSONValidity a => Validity (Const a b)Defined in validity-0.12.1.0 · Data.ValidityValid values the same as it's base type:
HasCodec a => HasCodec (Const a b)Defined in autodocodec-0.5.0.0 · Autodocodec.ClassMonoFoldable (Const m a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableMonoTraversable (Const m a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableMonoFunctor (Const m a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableMonoid m => MonoPointed (Const m a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversabletype Rep (Const a b) = D1 ('MetaData "Const"
"GHC.Internal.Data.Functor.Const"
"ghc-internal"
'True) (C1 ('MetaCons "Const"
'PrefixI 'True) (S1 ('MetaSel ('Just "getConst"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Consttype Rep1 (Const a) = D1 ('MetaData "Const"
"GHC.Internal.Data.Functor.Const"
"ghc-internal"
'True) (C1 ('MetaCons "Const"
'PrefixI 'True) (S1 ('MetaSel ('Just "getConst"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Constdata MVector s (Const a b)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Basedata Vector (Const a b)Defined in vector-0.13.2.0 · Data.Vector.Unboxed.Basetype Element (Const m a) = aDefined in mono-traversable-1.0.21.0 · Data.MonoTraversableWrapArrowunwrapArrow :: a b cGeneric1 (WrappedArrow a b)Defined in base-4.20.2.0 · Control.ApplicativeArrow a => Functor (WrappedArrow a b)Defined in base-4.20.2.0 · Control.ApplicativeArrow a => Applicative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.ApplicativeArrowPlus a => Alt (WrappedArrow a b)Defined in semigroupoids-6.0.1 · Data.Functor.AltArrow a => Apply (WrappedArrow a b)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassArrowPlus a => Plus (WrappedArrow a b)Defined in semigroupoids-6.0.1 · Data.Functor.Plus(Typeable a, Typeable b, Typeable c, Data (a b c)) => Data (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.ApplicativeGeneric (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.ApplicativeArbitrary (a b c) => Arbitrary (WrappedArrow a b c)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryArrow a => MonoFunctor (WrappedArrow a b c)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableArrow a => MonoPointed (WrappedArrow a b c)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversabletype 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))))Defined in base-4.20.2.0 · Control.Applicativetype Rep1 (WrappedArrow a b) = D1 ('MetaData "WrappedArrow"
"Control.Applicative"
"base"
'True) (C1 ('MetaCons "WrapArrow"
'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapArrow"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 (a b))))Defined in base-4.20.2.0 · Control.Applicativetype Element (WrappedArrow a b c) = cDefined in mono-traversable-1.0.21.0 · Data.MonoTraversableWrapMonadunwrapMonad :: m aGeneric1 (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Monad (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Functor (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonad m => Applicative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeMonadPlus m => Alternative (WrappedMonad m)Defined in base-4.20.2.0 · Control.Applicative(Distributive m, Monad m) => Distributive (WrappedMonad m)Defined in distributive-0.6.2.1 · Data.DistributiveMonadPlus m => Alt (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.AltMonad m => Apply (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassMonad m => Bind (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassMonadPlus m => Plus (WrappedMonad m)Defined in semigroupoids-6.0.1 · Data.Functor.Plus(Typeable m, Typeable a, Data (m a)) => Data (WrappedMonad m a)Defined in base-4.20.2.0 · Control.ApplicativeGeneric (WrappedMonad m a)Defined in base-4.20.2.0 · Control.ApplicativeArbitrary (m a) => Arbitrary (WrappedMonad m a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryMonad m => MonoFunctor (WrappedMonad m a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableMonad m => MonoPointed (WrappedMonad m a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversabletype 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))))Defined in base-4.20.2.0 · Control.Applicativetype Rep1 (WrappedMonad m) = D1 ('MetaData "WrappedMonad"
"Control.Applicative"
"base"
'True) (C1 ('MetaCons "WrapMonad"
'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonad"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 m)))Defined in base-4.20.2.0 · Control.Applicativetype Element (WrappedMonad m a) = aDefined in mono-traversable-1.0.21.0 · Data.MonoTraversableA variant of <*> with the types of the arguments reversed. It differs from
flip in that the effects are resolved in the order the arguments are
presented.(<*>)
(<**>) (print 1) (id <$ print 2)12
flip (<*>) (print 1) (id <$ print 2)21
ZipList [4, 5, 6] <**> ZipList [(+1), (*2), (/3)]ZipList {getZipList = [5.0,10.0,2.0]}
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.
Using the Applicative instance for Lists:
liftA (+1) [1, 2][2,3]
Or the Applicative instance for Maybe
liftA (+1) (Just 3)Just 4
Lift a ternary function to actions.
The sum of a collection of actions using (<|>), generalizing concat.
asum is just like msum, but generalised to Alternative.
Basic usage:
asum [Just "Hello", Nothing, Just "World"]Just "Hello"
Lists, but with an Applicative functor based on zipping.
In contrast to the Applicative for GHC.List.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]}
ZipListgetZipList :: [a]Functor ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListApplicative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListf <$> ZipList xs1 <*> ... <*> ZipList xsN
= ZipList (zipWithN f xs1 ... xsN)where zipWithN refers to the zipWith function of the appropriate arity
(zipWith, zipWith3, zipWith4, ...). For example:
(\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"]}Foldable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListTraversable ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListAlternative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListNFData1 ZipListDefined in deepseq-1.5.0.0 · Control.DeepSeqArbitrary1 ZipListDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryApply ZipListDefined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassAlign ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalSemialign ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalzipWith = .liftA2
Repeat ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalUnzip ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalZip ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalFilterable ZipListDefined in witherable-0.5 · WitherableWitherable ZipListDefined in witherable-0.5 · WitherableSelective ZipListDefined in selective-0.7.0.1 · Control.SelectiveGeneric1 ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListFoldableWithIndex Int ZipListDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Int ZipListDefined in indexed-traversable-0.1.4 · WithIndexSame instance as for [].
TraversableWithIndex Int ZipListDefined in indexed-traversable-0.1.4 · WithIndexRepeatWithIndex Int ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalSemialignWithIndex Int ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalZipWithIndex Int ZipListDefined in semialign-1.3.1 · Data.Semialign.InternalFilterableWithIndex Int ZipListDefined in witherable-0.5 · WitherableWitherableWithIndex Int ZipListDefined in witherable-0.5 · WitherableIsList (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.IsListEq a => Eq (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListData a => Data (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListOrd a => Ord (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListRead a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListShow a => Show (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListGeneric (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListNFData a => NFData (ZipList a)Defined in deepseq-1.5.0.0 · Control.DeepSeqArbitrary a => Arbitrary (ZipList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryCoArbitrary a => CoArbitrary (ZipList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.ArbitraryMonoFunctor (ZipList a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversableMonoPointed (ZipList a)Defined in mono-traversable-1.0.21.0 · Data.MonoTraversabletype Rep (ZipList a) = D1 ('MetaData "ZipList"
"GHC.Internal.Functor.ZipList"
"ghc-internal"
'True) (C1 ('MetaCons "ZipList"
'PrefixI 'True) (S1 ('MetaSel ('Just "getZipList"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListtype Rep1 ZipList = D1 ('MetaData "ZipList"
"GHC.Internal.Functor.ZipList"
"ghc-internal"
'True) (C1 ('MetaCons "ZipList"
'PrefixI 'True) (S1 ('MetaSel ('Just "getZipList"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 [])))Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListtype Item (ZipList a) = aDefined in ghc-internal-9.1003.0 · GHC.Internal.IsListtype Element (ZipList a) = aDefined in mono-traversable-1.0.21.0 · Data.MonoTraversable