Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type DsM = TcRnIf DsGblEnv DsLclEnv
- mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
- mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- initDs :: HscEnv -> TcGblEnv -> DsM a -> IO (Messages, Maybe a)
- initDsTc :: DsM a -> TcM a
- initTcDsForSolver :: TcM a -> DsM (Messages, Maybe a)
- initDsWithModGuts :: HscEnv -> ModGuts -> DsM a -> IO (Messages, Maybe a)
- fixDs :: (a -> DsM a) -> DsM a
- foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
- whenGOptM :: GeneralFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
- unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
- xoptM :: Extension -> TcRnIf gbl lcl Bool
- class Functor f => Applicative (f :: Type -> Type) where
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- duplicateLocalDs :: Id -> DsM Id
- newSysLocalDsNoLP :: Mult -> Type -> DsM Id
- newSysLocalDs :: Mult -> Type -> DsM Id
- newSysLocalsDsNoLP :: [Scaled Type] -> DsM [Id]
- newSysLocalsDs :: [Scaled Type] -> DsM [Id]
- newUniqueId :: Id -> Mult -> Type -> DsM Id
- newFailLocalDs :: Mult -> Type -> DsM Id
- newPredVarDs :: PredType -> DsM Var
- getSrcSpanDs :: DsM SrcSpan
- putSrcSpanDs :: SrcSpan -> DsM a -> DsM a
- mkPrintUnqualifiedDs :: DsM PrintUnqualified
- newUnique :: TcRnIf gbl lcl Unique
- data UniqSupply
- newUniqueSupply :: TcRnIf gbl lcl UniqSupply
- getGhcModeDs :: DsM GhcMode
- dsGetFamInstEnvs :: DsM FamInstEnvs
- dsLookupGlobal :: Name -> DsM TyThing
- dsLookupGlobalId :: Name -> DsM Id
- dsLookupTyCon :: Name -> DsM TyCon
- dsLookupDataCon :: Name -> DsM DataCon
- dsLookupConLike :: Name -> DsM ConLike
- type DsMetaEnv = NameEnv DsMetaVal
- data DsMetaVal
- dsGetMetaEnv :: DsM (NameEnv DsMetaVal)
- dsLookupMetaEnv :: Name -> DsM (Maybe DsMetaVal)
- dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a
- getPmDeltas :: DsM Deltas
- updPmDeltas :: Deltas -> DsM a -> DsM a
- dsGetCompleteMatches :: TyCon -> DsM [CompleteMatch]
- type DsWarning = (SrcSpan, SDoc)
- warnDs :: WarnReason -> SDoc -> DsM ()
- warnIfSetDs :: WarningFlag -> SDoc -> DsM ()
- errDs :: SDoc -> DsM ()
- errDsCoreExpr :: SDoc -> DsM CoreExpr
- failWithDs :: SDoc -> DsM a
- failDs :: DsM a
- discardWarningsDs :: DsM a -> DsM a
- askNoErrsDs :: DsM a -> DsM (a, Bool)
- data DsMatchContext = DsMatchContext (HsMatchContext GhcRn) SrcSpan
- data EquationInfo = EqnInfo {}
- data MatchResult a
- = MR_Infallible (DsM a)
- | MR_Fallible (CoreExpr -> DsM a)
- runMatchResult :: CoreExpr -> MatchResult a -> DsM a
- type DsWrapper = CoreExpr -> CoreExpr
- idDsWrapper :: DsWrapper
- dsNoLevPoly :: Type -> SDoc -> DsM ()
- dsNoLevPolyExpr :: CoreExpr -> SDoc -> DsM ()
- dsWhenNoErrs :: DsM a -> (a -> CoreExpr) -> DsM CoreExpr
- pprRuntimeTrace :: String -> SDoc -> CoreExpr -> DsM CoreExpr
Documentation
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) Source #
Map each element of a structure to a monadic action, evaluate
these actions from left to right, and collect the results. For
a version that ignores the results see mapM_
.
Examples
mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) Source #
The mapAndUnzipM
function maps its first argument over a list, returning
the result as a pair of lists. This function is mainly used with complicated
data structures or a state monad.
foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b Source #
Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.
Examples
Basic usage:
>>>
foldlM (\acc string -> print string >> pure (acc + length string)) 42 ["Hello", "world", "!"]
"Hello" "world" "!" 53
foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b Source #
Monadic fold over the elements of a structure, associating to the right, i.e. from right to left.
Examples
Basic usage:
>>>
foldrM (\string acc -> print string >> pure (acc + length string)) 42 ["Hello", "world", "!"]
"!" "world" "Hello" 53
unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a Source #
unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a Source #
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:
(<*>
) =liftA2
id
liftA2
f x y = f<$>
x<*>
y
Further, any definition must satisfy the following:
- Identity
pure
id
<*>
v = v- Composition
pure
(.)<*>
u<*>
v<*>
w = u<*>
(v<*>
w)- Homomorphism
pure
f<*>
pure
x =pure
(f x)- Interchange
u
<*>
pure
y =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
liftA2
p (liftA2
q u v) =liftA2
f u .liftA2
g v
If f
is also a Monad
, it should satisfy
(which implies that pure
and <*>
satisfy the applicative functor laws).
Lift a value.
(<*>) :: 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.
Using ApplicativeDo
: 'fs
' can be understood as
the <*>
asdo
expression
do f <- fs a <- as pure (f a)
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
.
Using ApplicativeDo
: '
' can be understood
as the liftA2
f as bsdo
expression
do a <- as b <- bs pure (f a b)
(*>) :: f a -> f b -> f b infixl 4 Source #
Sequence actions, discarding the value of the first argument.
'as
' can be understood as the *>
bsdo
expression
do as bs
This is a tad complicated for our ApplicativeDo
extension
which will give it a Monad
constraint. For an Applicative
constraint we write it of the form
do _ <- as b <- bs pure b
(<*) :: f a -> f b -> f a infixl 4 Source #
Sequence actions, discarding the value of the second argument.
Using ApplicativeDo
: 'as
' can be understood as
the <*
bsdo
expression
do a <- as bs pure a
Instances
Applicative [] | Since: base-2.1 |
Applicative Maybe | Since: base-2.1 |
Applicative IO | Since: base-2.1 |
Applicative Par1 | Since: base-4.9.0.0 |
Applicative Q | |
Applicative Complex | Since: base-4.9.0.0 |
Applicative Min | Since: base-4.9.0.0 |
Applicative Max | Since: base-4.9.0.0 |
Applicative First | Since: base-4.9.0.0 |
Applicative Last | Since: base-4.9.0.0 |
Applicative Option | Since: base-4.9.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 |
Applicative Identity | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity | |
Applicative STM | Since: base-4.8.0.0 |
Applicative First | Since: base-4.8.0.0 |
Applicative Last | Since: base-4.8.0.0 |
Applicative Dual | Since: base-4.8.0.0 |
Applicative Sum | Since: base-4.8.0.0 |
Applicative Product | Since: base-4.8.0.0 |
Defined in Data.Semigroup.Internal | |
Applicative Down | Since: base-4.11.0.0 |
Applicative ReadPrec | Since: base-4.6.0.0 |
Defined in Text.ParserCombinators.ReadPrec | |
Applicative ReadP | Since: base-4.6.0.0 |
Applicative NonEmpty | Since: base-4.9.0.0 |
Applicative PutM | |
Applicative Get | |
Applicative Put | |
Applicative Tree | |
Applicative Seq | Since: containers-0.5.4 |
Applicative Capability | |
Defined in System.Console.Terminfo.Base pure :: a -> Capability a Source # (<*>) :: Capability (a -> b) -> Capability a -> Capability b Source # liftA2 :: (a -> b -> c) -> Capability a -> Capability b -> Capability c Source # (*>) :: Capability a -> Capability b -> Capability b Source # (<*) :: Capability a -> Capability b -> Capability a Source # | |
Applicative P | Since: base-4.5.0.0 |
Applicative UniqSM # | |
Applicative Pair # | |
Applicative UnifyResultM # | |
Defined in GHC.Core.Unify pure :: a -> UnifyResultM a Source # (<*>) :: UnifyResultM (a -> b) -> UnifyResultM a -> UnifyResultM b Source # liftA2 :: (a -> b -> c) -> UnifyResultM a -> UnifyResultM b -> UnifyResultM c Source # (*>) :: UnifyResultM a -> UnifyResultM b -> UnifyResultM b Source # (<*) :: UnifyResultM a -> UnifyResultM b -> UnifyResultM a Source # | |
Applicative P # | |
Applicative CoreM # | |
Applicative PV # | |
Applicative LiftM # | |
Applicative Hsc # | |
Applicative CompPipeline # | |
Defined in GHC.Driver.Pipeline.Monad pure :: a -> CompPipeline a Source # (<*>) :: CompPipeline (a -> b) -> CompPipeline a -> CompPipeline b Source # liftA2 :: (a -> b -> c) -> CompPipeline a -> CompPipeline b -> CompPipeline c Source # (*>) :: CompPipeline a -> CompPipeline b -> CompPipeline b Source # (<*) :: CompPipeline a -> CompPipeline b -> CompPipeline a Source # | |
Applicative Ghc # | |
Applicative SimplM # | |
Applicative TcPluginM # | |
Defined in GHC.Tc.Types | |
Applicative PD # | |
Applicative MetaTyVarUpdateResult # | |
Defined in GHC.Tc.Utils.Unify pure :: a -> MetaTyVarUpdateResult a Source # (<*>) :: MetaTyVarUpdateResult (a -> b) -> MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b Source # liftA2 :: (a -> b -> c) -> MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult c Source # (*>) :: MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult b Source # (<*) :: MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult a Source # | |
Applicative TcS # | |
Applicative CpsRn # | |
Applicative MatchResult # | Product is an "or" on falliblity---the combined match result is infallible only if the left and right argument match results both were. This is useful for combining a bunch of alternatives together and then
getting the overall falliblity of the entire group. See |
Defined in GHC.HsToCore.Monad pure :: a -> MatchResult a Source # (<*>) :: MatchResult (a -> b) -> MatchResult a -> MatchResult b Source # liftA2 :: (a -> b -> c) -> MatchResult a -> MatchResult b -> MatchResult c Source # (*>) :: MatchResult a -> MatchResult b -> MatchResult b Source # (<*) :: MatchResult a -> MatchResult b -> MatchResult a Source # | |
Applicative LlvmM # | |
Applicative NatM # | |
Applicative FCode # | |
Applicative CmmParse # | |
Defined in GHC.StgToCmm.ExtCode | |
Applicative (Either e) | Since: base-3.0 |
Defined in Data.Either | |
Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017) Since: base-2.1 |
Applicative (ST s) | Since: base-4.4.0.0 |
Monad m => Applicative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative 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 # | |
Arrow a => Applicative (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in Control.Arrow 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 (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
(Functor m, Monad m) => Applicative (MaybeT m) | |
Defined in Control.Monad.Trans.Maybe | |
Applicative m => Applicative (ListT m) | |
Defined in Control.Monad.Trans.List | |
Applicative (State s) # | |
Applicative (MaybeErr err) # | |
Defined in GHC.Data.Maybe pure :: a -> MaybeErr err a Source # (<*>) :: MaybeErr err (a -> b) -> MaybeErr err a -> MaybeErr err b Source # liftA2 :: (a -> b -> c) -> MaybeErr err a -> MaybeErr err b -> MaybeErr err c Source # (*>) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err b Source # (<*) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err a Source # | |
Applicative (SetM s) | |
Applicative (CmdLineP s) # | |
Defined in GHC.Driver.CmdLine pure :: a -> CmdLineP s a Source # (<*>) :: CmdLineP s (a -> b) -> CmdLineP s a -> CmdLineP s b Source # liftA2 :: (a -> b -> c) -> CmdLineP s a -> CmdLineP s b -> CmdLineP s c Source # (*>) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s b Source # (<*) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s a Source # | |
Monad m => Applicative (EwM m) # | |
Applicative (IOEnv m) # | |
Applicative m => Applicative (GhcT m) # | |
Applicative (RegM freeRegs) # | |
Defined in GHC.CmmToAsm.Reg.Linear.State pure :: a -> RegM freeRegs a Source # (<*>) :: RegM freeRegs (a -> b) -> RegM freeRegs a -> RegM freeRegs b Source # liftA2 :: (a -> b -> c) -> RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs c Source # (*>) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs b Source # (<*) :: RegM freeRegs a -> RegM freeRegs b -> RegM freeRegs a Source # | |
Applicative f => Applicative (Rec1 f) | Since: base-4.9.0.0 |
(Monoid a, Monoid b) => Applicative ((,,) a b) | Since: base-4.14.0.0 |
Defined in GHC.Base | |
Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative 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 m => Applicative (Kleisli m a) | Since: base-4.14.0.0 |
Defined in Control.Arrow 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 |
Applicative f => Applicative (Ap f) | Since: base-4.12.0.0 |
Applicative f => Applicative (Alt f) | Since: base-4.8.0.0 |
(Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal 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 # | |
(Functor m, Monad m) => Applicative (ExceptT e m) | |
Defined in Control.Monad.Trans.Except 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 # | |
(Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Strict 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 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 # | |
(Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict 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.Lazy 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 # | |
Applicative m => Applicative (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader 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 # | |
Applicative m => Applicative (IdentityT m) | |
Defined in Control.Monad.Trans.Identity 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 # | |
(Functor m, Monad m) => Applicative (ErrorT e m) | |
Defined in Control.Monad.Trans.Error pure :: a -> ErrorT e m a Source # (<*>) :: ErrorT e m (a -> b) -> ErrorT e m a -> ErrorT e m b Source # liftA2 :: (a -> b -> c) -> ErrorT e m a -> ErrorT e m b -> ErrorT e m c Source # (*>) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m b Source # (<*) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m a Source # | |
Monad m => Applicative (Stream m a) # | |
Defined in GHC.Data.Stream pure :: a0 -> Stream m a a0 Source # (<*>) :: Stream m a (a0 -> b) -> Stream m a a0 -> Stream m a b Source # liftA2 :: (a0 -> b -> c) -> Stream m a a0 -> Stream m a b -> Stream m a c Source # (*>) :: Stream m a a0 -> Stream m a b -> Stream m a b Source # (<*) :: Stream m a a0 -> Stream m a b -> Stream m a a0 Source # | |
Monoid c => Applicative (K1 i c :: Type -> Type) | Since: base-4.12.0.0 |
(Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Applicative ((->) r) | Since: base-2.1 |
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) | Since: base-4.14.0.0 |
Defined in GHC.Base 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 f, Applicative g) => Applicative (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product 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 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 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 (ContT r m) | |
Defined in Control.Monad.Trans.Cont | |
Applicative f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
(Applicative f, Applicative g) => Applicative (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose 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 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 # | |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Strict 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 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 # | |
(Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.CPS 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 # |
(<$>) :: 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
String
show
:
>>>
show <$> Nothing
Nothing>>>
show <$> Just 3
Just "3"
Convert from an
to an
Either
Int
Int
Either
Int
String
using show
:
>>>
show <$> Left 17
Left 17>>>
show <$> Right 17
Right "17"
Double each element of a list:
>>>
(*2) <$> [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
even <$> (2,2)
(2,True)
data UniqSupply Source #
Unique Supply
A value of type UniqSupply
is unique, and it can
supply one distinct Unique
. Also, from the supply, one can
also manufacture an arbitrary number of further UniqueSupply
values,
which will be distinct from the first and from all others.
newUniqueSupply :: TcRnIf gbl lcl UniqSupply Source #
getPmDeltas :: DsM Deltas Source #
Get the current pattern match oracle state. See dsl_deltas
.
updPmDeltas :: Deltas -> DsM a -> DsM a Source #
Set the pattern match oracle state within the scope of the given action.
See dsl_deltas
.
dsGetCompleteMatches :: TyCon -> DsM [CompleteMatch] Source #
The COMPLETE
pragmas provided by the user for a given TyCon
.
warnDs :: WarnReason -> SDoc -> DsM () Source #
Emit a warning for the current source location NB: Warns whether or not -Wxyz is set
warnIfSetDs :: WarningFlag -> SDoc -> DsM () Source #
Emit a warning only if the correct WarnReason is set in the DynFlags
errDsCoreExpr :: SDoc -> DsM CoreExpr Source #
Issue an error, but return the expression for (), so that we can continue reporting errors.
failWithDs :: SDoc -> DsM a Source #
discardWarningsDs :: DsM a -> DsM a Source #
data DsMatchContext Source #
Instances
Outputable DsMatchContext # | |
Defined in GHC.HsToCore.Monad |
data EquationInfo Source #
EqnInfo | |
|
Instances
Outputable EquationInfo # | |
Defined in GHC.HsToCore.Monad |
data MatchResult a Source #
This is a value of type a with potentially a CoreExpr-shaped hole in it. This is used to deal with cases where we are potentially handling pattern match failure, and want to later specify how failure is handled.
MR_Infallible (DsM a) | We represent the case where there is no hole without a function from
|
MR_Fallible (CoreExpr -> DsM a) |
Instances
Functor MatchResult # | |
Defined in GHC.HsToCore.Monad fmap :: (a -> b) -> MatchResult a -> MatchResult b Source # (<$) :: a -> MatchResult b -> MatchResult a Source # | |
Applicative MatchResult # | Product is an "or" on falliblity---the combined match result is infallible only if the left and right argument match results both were. This is useful for combining a bunch of alternatives together and then
getting the overall falliblity of the entire group. See |
Defined in GHC.HsToCore.Monad pure :: a -> MatchResult a Source # (<*>) :: MatchResult (a -> b) -> MatchResult a -> MatchResult b Source # liftA2 :: (a -> b -> c) -> MatchResult a -> MatchResult b -> MatchResult c Source # (*>) :: MatchResult a -> MatchResult b -> MatchResult b Source # (<*) :: MatchResult a -> MatchResult b -> MatchResult a Source # |
runMatchResult :: CoreExpr -> MatchResult a -> DsM a Source #
dsNoLevPoly :: Type -> SDoc -> DsM () Source #
Fail with an error message if the type is levity polymorphic.
dsNoLevPolyExpr :: CoreExpr -> SDoc -> DsM () Source #
Check an expression for levity polymorphism, failing if it is levity polymorphic.
dsWhenNoErrs :: DsM a -> (a -> CoreExpr) -> DsM CoreExpr Source #
Runs the thing_inside. If there are no errors, then returns the expr given. Otherwise, returns unitExpr. This is useful for doing a bunch of levity polymorphism checks and then avoiding making a core App. (If we make a core App on a levity polymorphic argument, detecting how to handle the let/app invariant might call isUnliftedType, which panics on a levity polymorphic type.) See #12709 for an example of why this machinery is necessary.
Inject a trace message into the compiled program. Whereas pprTrace prints out information *while compiling*, pprRuntimeTrace captures that information and causes it to be printed *at runtime* using Debug.Trace.trace.
pprRuntimeTrace hdr doc expr
will produce an expression that looks like
trace (hdr + doc) expr
When using this to debug a module that Debug.Trace depends on, it is necessary to import {--} Debug.Trace () in that module. We could avoid this inconvenience by wiring in Debug.Trace.trace, but that doesn't seem worth the effort and maintenance cost.