ghc-7.8.2: The GHC API

Safe Haskell | None
Language | Haskell98

DsMonad

Synopsis

- type DsM result = TcRnIf DsGblEnv DsLclEnv result
- mapM :: Monad m => (a -> m b) -> [a] -> m [b]
- mapAndUnzipM :: Monad m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- initDs :: HscEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv -> DsM a -> IO (Messages, Maybe a)
- initDsTc :: DsM a -> TcM 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
- class Functor f => Applicative f where
  - pure :: a -> f a
  - (<*>) :: f (a -> b) -> f a -> f b
  - (*>) :: f a -> f b -> f b
  - (<*) :: f a -> f b -> f a
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- newLocalName :: Name -> TcM Name
- duplicateLocalDs :: Id -> DsM Id
- newSysLocalDs :: 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
- 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
  - = Bound Id
  - | Splice (HsExpr Id)
- dsGetMetaEnv :: DsM (NameEnv DsMetaVal)
- dsLookupMetaEnv :: Name -> DsM (Maybe DsMetaVal)
- dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a
- type DsWarning = (SrcSpan, SDoc)
- warnDs :: SDoc -> DsM ()
- failWithDs :: SDoc -> DsM a
- discardWarningsDs :: DsM a -> DsM a
- 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
  - = CanFail
  - | CantFail
- orFail :: CanItFail -> CanItFail -> CanItFail

# Documentation

type DsM result = TcRnIf DsGblEnv DsLclEnv result

mapM :: Monad m => (a -> m b) -> [a] -> m [b] Source

``mapM` f` is equivalent to ``sequence` . `map` f`.

mapAndUnzipM :: Monad 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-transforming monad.

initDs :: HscEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv -> DsM a -> IO (Messages, Maybe a)

initDsTc :: DsM a -> TcM a

fixDs :: (a -> DsM a) -> DsM a

foldlM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a

Monadic version of foldl

foldrM :: Monad m => (b -> a -> m a) -> a -> [b] -> m a

Monadic version of foldr

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

class Functor f => Applicative f where Source

A functor with application, providing operations to

- embed pure expressions (`pure`), and
- sequence computations and combine their results (`<*>`).

A minimal complete definition must include implementations of these functions satisfying the following laws:

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:

-     u *> v = pure (const id) <*> u <*> v

-     u <* v = pure const <*> u <*> v

As a consequence of these laws, the `Functor` instance for `f` will satisfy

-     fmap f x = pure f <*> x

If `f` is also a `Monad`, it should satisfy

-     pure = return

-     (<*>) = ap

(which implies that `pure` and `<*>` satisfy the applicative functor laws).

Minimal complete definition

pure, (<*>)

Methods

pure :: a -> f a Source

Lift a value.

(<*>) :: f (a -> b) -> f a -> f b infixl 4 Source

Sequential application.

(*>) :: f a -> f b -> f b infixl 4 Source

Sequence actions, discarding the value of the first argument.

(<*) :: f a -> f b -> f a infixl 4 Source

Sequence actions, discarding the value of the second argument.

Instances

Applicative [] |
Applicative IO |
Applicative Q |
Applicative Maybe |
Applicative ParseResult |
Applicative Id |
Applicative ZipList |
Applicative STM |
Applicative ReadPrec |
Applicative ReadP |
Applicative Id |
Applicative Seq |
Applicative VM |
Applicative SimpleUniqueMonad |
Applicative PprM |
Applicative Pair |
Applicative UniqSM |
Applicative OccCheckResult |
Applicative LlvmM |
Applicative FCode |
Applicative CmmParse |
Applicative NatM |
Applicative Hsc |
Applicative Ghc |
Applicative CompPipeline |
Applicative CpsRn |
Applicative TcS |
Applicative VM |
Applicative CoreM |
Applicative SimplM |
Applicative ((->) a) |
Applicative (Either e) |
Monoid a => Applicative ((,) a) |
Applicative (ST s) |
Applicative (StateL s) |
Applicative (StateR s) |
Monoid m => Applicative (Const m) |
Monad m => Applicative (WrappedMonad m) |
Applicative (ST s) |
Arrow a => Applicative (ArrowMonad a) |
Applicative (Proxy *) |
Applicative (State s) |
Monad m => Applicative (CheckingFuelMonad m) |
Monad m => Applicative (InfiniteFuelMonad m) |
Monad m => Applicative (UniqueMonadT m) |
Applicative (MaybeErr err) |
(Monad m, Functor m) => Applicative (MaybeT m) |
Applicative (State s) |
Applicative (CmdLineP s) |
Monad m => Applicative (EwM m) |
Applicative (IOEnv m) |
Applicative (RegM freeRegs) |
Applicative m => Applicative (GhcT m) |
Arrow a => Applicative (WrappedArrow a b) |
(Functor m, Monad m) => Applicative (StateT s m) |
Monad m => Applicative (Stream m a) |
Typeable ((* -> *) -> Constraint) Applicative |

(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source

An infix synonym for `fmap`.

newLocalName :: Name -> TcM Name

duplicateLocalDs :: Id -> DsM Id

newSysLocalDs :: 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

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

getGhcModeDs :: DsM GhcMode

dsGetFamInstEnvs :: DsM FamInstEnvs

dsLookupGlobal :: Name -> DsM TyThing

dsLookupGlobalId :: Name -> DsM Id

dsDPHBuiltin :: (PArrBuiltin -> a) -> DsM a

Get a name from Data.Array.Parallel for the desugarer, from the `ds_parr_bi` component of the global desugerar environment.

dsLookupTyCon :: Name -> DsM TyCon

dsLookupDataCon :: Name -> DsM DataCon

data PArrBuiltin

Constructors

PArrBuiltin |
Fields lengthPVar :: Var lengthP replicatePVar :: Var replicateP singletonPVar :: Var singletonP mapPVar :: Var mapP filterPVar :: Var filterP zipPVar :: Var zipP crossMapPVar :: Var crossMapP indexPVar :: Var (!:) emptyPVar :: Var emptyP appPVar :: Var (+:+) enumFromToPVar :: Var enumFromToP enumFromThenToPVar :: Var enumFromThenToP

dsLookupDPHRdrEnv :: OccName -> DsM Name

Lookup a name exported by `Prim` or `Prim`. Panic if there isn't one, or if it is defined multiple times.

dsLookupDPHRdrEnv_maybe :: OccName -> DsM (Maybe Name)

Lookup a name exported by `Prim` or `Prim`, returning `Nothing` if it's not defined. Panic if it's defined multiple times.

dsInitPArrBuiltin :: DsM a -> DsM a

type DsMetaEnv = NameEnv DsMetaVal

data DsMetaVal

Constructors

Bound Id |
Splice (HsExpr Id) |

dsGetMetaEnv :: DsM (NameEnv DsMetaVal)

dsLookupMetaEnv :: Name -> DsM (Maybe DsMetaVal)

dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a

type DsWarning = (SrcSpan, SDoc)

warnDs :: SDoc -> DsM ()

failWithDs :: SDoc -> DsM a

discardWarningsDs :: DsM a -> DsM a

data DsMatchContext

Constructors

DsMatchContext (HsMatchContext Name) SrcSpan |

data EquationInfo

Constructors

EqnInfo |
Fields eqn_pats :: [Pat Id] eqn_rhs :: MatchResult

Instances

Outputable EquationInfo |

data MatchResult

Constructors

MatchResult CanItFail (CoreExpr -> DsM CoreExpr) |

type DsWrapper = CoreExpr -> CoreExpr

idDsWrapper :: DsWrapper

data CanItFail

Constructors

CanFail |
CantFail |

orFail :: CanItFail -> CanItFail -> CanItFail