Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type DsM = TcRnIf DsGblEnv DsLclEnv
- mapM :: Traversable t => forall (m :: * -> *) a b. 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 :: Monad m => (a -> b -> m a) -> a -> [b] -> m a
- foldrM :: Monad m => (b -> a -> m a) -> a -> [b] -> m a
- 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 :: * -> *) where
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- duplicateLocalDs :: Id -> DsM Id
- newSysLocalDsNoLP :: Type -> DsM Id
- newSysLocalDs :: Type -> DsM Id
- newSysLocalsDsNoLP :: [Type] -> DsM [Id]
- newSysLocalsDs :: [Type] -> DsM [Id]
- newUniqueId :: Id -> Type -> DsM Id
- newFailLocalDs :: 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
- dsDPHBuiltin :: (PArrBuiltin -> a) -> DsM a
- dsLookupTyCon :: Name -> DsM TyCon
- dsLookupDataCon :: Name -> DsM DataCon
- dsLookupConLike :: Name -> DsM ConLike
- data PArrBuiltin = PArrBuiltin {
- lengthPVar :: Var
- replicatePVar :: Var
- singletonPVar :: Var
- mapPVar :: Var
- filterPVar :: Var
- zipPVar :: Var
- crossMapPVar :: Var
- indexPVar :: Var
- emptyPVar :: Var
- appPVar :: Var
- enumFromToPVar :: Var
- enumFromThenToPVar :: Var
- dsLookupDPHRdrEnv :: OccName -> DsM Name
- dsLookupDPHRdrEnv_maybe :: OccName -> DsM (Maybe Name)
- dsInitPArrBuiltin :: DsM a -> DsM a
- type DsMetaEnv = NameEnv DsMetaVal
- data DsMetaVal
- dsGetMetaEnv :: DsM (NameEnv DsMetaVal)
- dsLookupMetaEnv :: Name -> DsM (Maybe DsMetaVal)
- dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a
- getDictsDs :: DsM (Bag EvVar)
- addDictsDs :: Bag EvVar -> DsM a -> DsM a
- getTmCsDs :: DsM (Bag SimpleEq)
- addTmCsDs :: Bag SimpleEq -> DsM a -> DsM a
- incrCheckPmIterDs :: DsM Int
- resetPmIterDs :: DsM ()
- 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 Name) SrcSpan
- data EquationInfo = EqnInfo {
- eqn_pats :: [Pat Id]
- eqn_rhs :: MatchResult
- data MatchResult = MatchResult CanItFail (CoreExpr -> DsM CoreExpr)
- type DsWrapper = CoreExpr -> CoreExpr
- idDsWrapper :: DsWrapper
- data CanItFail
- orFail :: CanItFail -> CanItFail -> CanItFail
- dsNoLevPoly :: Type -> SDoc -> DsM ()
- dsNoLevPolyExpr :: CoreExpr -> SDoc -> DsM ()
- dsWhenNoErrs :: DsM a -> (a -> CoreExpr) -> DsM CoreExpr
Documentation
mapM :: Traversable t => forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b) #
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_
.
mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) #
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-transforming monad.
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 :: * -> *) where #
A functor with application, providing operations to
A minimal complete definition must include implementations of pure
and of either <*>
or liftA2
. If it defines both, then they must behave
the same as their default definitions:
(
<*>
) = 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 #
Sequential application.
A few functors support an implementation of <*>
that is more
efficient than the default one.
(*>) :: f a -> f b -> f b infixl 4 #
Sequence actions, discarding the value of the first argument.
(<*) :: f a -> f b -> f a infixl 4 #
Sequence actions, discarding the value of the second argument.
Applicative [] | Since: 2.1 |
Applicative Maybe | Since: 2.1 |
Applicative IO | Since: 2.1 |
Applicative Par1 | Since: 4.9.0.0 |
Applicative Q | |
Applicative P | Since: 4.5.0.0 |
Applicative Complex | Since: 4.9.0.0 |
Applicative Min | Since: 4.9.0.0 |
Applicative Max | Since: 4.9.0.0 |
Applicative First | Since: 4.9.0.0 |
Applicative Last | Since: 4.9.0.0 |
Applicative Option | Since: 4.9.0.0 |
Applicative NonEmpty | Since: 4.9.0.0 |
Applicative ZipList | f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
|
Applicative Identity | Since: 4.8.0.0 |
Applicative STM | Since: 4.8.0.0 |
Applicative Dual | Since: 4.8.0.0 |
Applicative Sum | Since: 4.8.0.0 |
Applicative Product | Since: 4.8.0.0 |
Applicative First | |
Applicative Last | |
Applicative ReadPrec | Since: 4.6.0.0 |
Applicative ReadP | Since: 4.6.0.0 |
Applicative PutM | |
Applicative Get | |
Applicative Put | |
Applicative Tree | |
Applicative Seq | |
Applicative VM | |
Applicative SimpleUniqueMonad | |
Applicative Capability | |
Applicative Pair # | |
Applicative UniqSM # | |
Applicative P # | |
Applicative PD # | |
Applicative UnifyResultM # | |
Applicative LlvmM # | |
Applicative FCode # | |
Applicative CmmParse # | |
Applicative Hsc # | |
Applicative TcPluginM # | |
Applicative CompPipeline # | |
Applicative Ghc # | |
Applicative CoreM # | |
Applicative SimplM # | |
Applicative CpsRn # | |
Applicative OccCheckResult # | |
Applicative TcS # | |
Applicative VM # | |
Applicative NatM # | |
Applicative (Either e) | Since: 3.0 |
Applicative (U1 *) | Since: 4.9.0.0 |
Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017) Since: 2.1 |
Applicative (ST s) | Since: 4.4.0.0 |
Monad m => Applicative (WrappedMonad m) | Since: 2.1 |
Arrow a => Applicative (ArrowMonad a) | Since: 4.6.0.0 |
Applicative (Proxy *) | Since: 4.7.0.0 |
Applicative (SetM s) | |
Applicative (State s) | |
Monad m => Applicative (CheckingFuelMonad m) | |
Monad m => Applicative (InfiniteFuelMonad m) | |
Monad m => Applicative (UniqueMonadT m) | |
(Functor m, Monad m) => Applicative (MaybeT m) | |
Applicative (ListT f) # | |
Applicative (State s) # | |
Applicative (MaybeErr err) # | |
Applicative (CmdLineP s) # | |
Monad m => Applicative (EwM m) # | |
Applicative (IOEnv m) # | |
Applicative (RegM freeRegs) # | |
Applicative m => Applicative (GhcT m) # | |
Applicative f => Applicative (Rec1 * f) | Since: 4.9.0.0 |
Arrow a => Applicative (WrappedArrow a b) | Since: 2.1 |
Monoid m => Applicative (Const * m) | Since: 2.0.1 |
Applicative f => Applicative (Alt * f) | |
(Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to |
(Monoid w, Applicative m) => Applicative (WriterT w m) | |
(Functor m, Monad m) => Applicative (StateT s m) | |
(Functor m, Monad m) => Applicative (StateT s m) | |
(Functor m, Monad m) => Applicative (ExceptT e m) | |
Monad m => Applicative (Stream m a) # | |
Applicative ((->) LiftedRep LiftedRep a) | Since: 2.1 |
(Applicative f, Applicative g) => Applicative ((:*:) * f g) | Since: 4.9.0.0 |
(Monad f, Applicative f) => Applicative (WhenMatched f x y) | Equivalent to |
(Applicative f, Monad f) => Applicative (WhenMissing f k x) | Equivalent to |
Applicative m => Applicative (ReaderT * r m) | |
Applicative f => Applicative (M1 * i c f) | Since: 4.9.0.0 |
(Applicative f, Applicative g) => Applicative ((:.:) * * f g) | Since: 4.9.0.0 |
(Monad f, Applicative f) => Applicative (WhenMatched f k x y) | Equivalent to |
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #
An infix synonym for fmap
.
The name of this operator is an allusion to $
.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $
is function application, <$>
is function
application lifted over a Functor
.
Examples
Convert from a
to a Maybe
Int
using Maybe
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 #
dsDPHBuiltin :: (PArrBuiltin -> a) -> DsM a Source #
Get a name from Data.Array.Parallel for the desugarer, from the
ds_parr_bi
component of the global desugerar environment.
data PArrBuiltin Source #
PArrBuiltin | |
|
dsInitPArrBuiltin :: DsM a -> DsM a Source #
Populate ds_parr_bi
from ds_dph_env
.
incrCheckPmIterDs :: DsM Int Source #
Increase the counter for elapsed pattern match check iterations. If the current counter is already over the limit, fail
resetPmIterDs :: DsM () Source #
Reset the counter for pattern match check iterations to zero
dsGetCompleteMatches :: TyCon -> DsM [CompleteMatch] Source #
The COMPLETE
pragams 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 #
data EquationInfo Source #
data MatchResult 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.