ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Data.IOEnv

Description

The IO Monad with an environment

The environment is passed around as a Reader monad but as its in the IO monad, mutable references can be used for updating state.

Synopsis

- data IOEnv env a
- module GHC.Utils.Monad
- failM :: IOEnv env a
- failWithM :: String -> IOEnv env a
- data IOEnvFailure = IOEnvFailure
- getEnv :: IOEnv env env
- setEnv :: env' -> IOEnv env' a -> IOEnv env a
- updEnv :: (env -> env') -> IOEnv env' a -> IOEnv env a
- runIOEnv :: env -> IOEnv env a -> IO a
- unsafeInterleaveM :: IOEnv env a -> IOEnv env a
- uninterruptibleMaskM_ :: IOEnv env a -> IOEnv env a
- tryM :: IOEnv env r -> IOEnv env (Either IOEnvFailure r)
- tryAllM :: IOEnv env r -> IOEnv env (Either SomeException r)
- tryMostM :: IOEnv env r -> IOEnv env (Either SomeException r)
- fixM :: (a -> IOEnv env a) -> IOEnv env a
- data IORef a
- newMutVar :: a -> IOEnv env (IORef a)
- readMutVar :: IORef a -> IOEnv env a
- writeMutVar :: IORef a -> a -> IOEnv env ()
- updMutVar :: IORef a -> (a -> a) -> IOEnv env ()
- updMutVarM :: IORef a -> (a -> IOEnv env a) -> IOEnv env ()
- atomicUpdMutVar :: IORef a -> (a -> (a, b)) -> IOEnv env b
- atomicUpdMutVar' :: IORef a -> (a -> (a, b)) -> IOEnv env b

# Documentation

data IOEnv env a Source #

#### Instances

Instances details

Quasi TcM Source # |

Instance details

Defined in GHC.Tc.Gen.Splice

Methods

qNewName :: String -> TcM Name Source #

qReport :: Bool -> String -> TcM () Source #

qRecover :: TcM a -> TcM a -> TcM a Source #

qLookupName :: Bool -> String -> TcM (Maybe Name) Source #

qReify :: Name -> TcM Info Source #

qReifyFixity :: Name -> TcM (Maybe Fixity) Source #

qReifyType :: Name -> TcM Type Source #

qReifyInstances :: Name -> [Type] -> TcM [Dec] Source #

qReifyRoles :: Name -> TcM [Role] Source #

qReifyAnnotations :: Data a => AnnLookup -> TcM [a] Source #

qReifyModule :: Module -> TcM ModuleInfo Source #

qReifyConStrictness :: Name -> TcM [DecidedStrictness] Source #

qLocation :: TcM Loc Source #

qRunIO :: IO a -> TcM a Source #

qGetPackageRoot :: TcM FilePath Source #

qAddDependentFile :: FilePath -> TcM () Source #

qAddTempFile :: String -> TcM FilePath Source #

qAddTopDecls :: [Dec] -> TcM () Source #

qAddForeignFilePath :: ForeignSrcLang -> String -> TcM () Source #

qAddModFinalizer :: Q () -> TcM () Source #

qAddCorePlugin :: String -> TcM () Source #

qGetQ :: Typeable a => TcM (Maybe a) Source #

qPutQ :: Typeable a => a -> TcM () Source #

qIsExtEnabled :: Extension -> TcM Bool Source #

qExtsEnabled :: TcM [Extension] Source #

qPutDoc :: DocLoc -> String -> TcM () Source #

qGetDoc :: DocLoc -> TcM (Maybe String) Source #

MonadFail (IOEnv m) Source # |
Instance details Defined in GHC.Data.IOEnv Methods fail :: String -> IOEnv m a Source #
MonadFix (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods mfix :: (a -> IOEnv env a) -> IOEnv env a Source #
MonadIO (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods liftIO :: IO a -> IOEnv env a Source #
Alternative (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods empty :: IOEnv env a Source # (<|>) :: IOEnv env a -> IOEnv env a -> IOEnv env a Source # some :: IOEnv env a -> IOEnv env [a] Source # many :: IOEnv env a -> IOEnv env [a] Source #
Applicative (IOEnv m) Source # |
Instance details Defined in GHC.Data.IOEnv Methods pure :: a -> IOEnv m a Source # (<*>) :: IOEnv m (a -> b) -> IOEnv m a -> IOEnv m b Source # liftA2 :: (a -> b -> c) -> IOEnv m a -> IOEnv m b -> IOEnv m c Source # (*>) :: IOEnv m a -> IOEnv m b -> IOEnv m b Source # (<*) :: IOEnv m a -> IOEnv m b -> IOEnv m a Source #
Functor (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods fmap :: (a -> b) -> IOEnv env a -> IOEnv env b Source # (<$) :: a -> IOEnv env b -> IOEnv env a Source #
Monad (IOEnv m) Source # |
Instance details Defined in GHC.Data.IOEnv Methods (>>=) :: IOEnv m a -> (a -> IOEnv m b) -> IOEnv m b Source # (>>) :: IOEnv m a -> IOEnv m b -> IOEnv m b Source # return :: a -> IOEnv m a Source #
MonadPlus (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods mzero :: IOEnv env a Source # mplus :: IOEnv env a -> IOEnv env a -> IOEnv env a Source #
MonadCatch (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods catch :: (HasCallStack, Exception e) => IOEnv env a -> (e -> IOEnv env a) -> IOEnv env a Source #
MonadMask (IOEnv env) Source # |

Instance details

Defined in GHC.Data.IOEnv

Methods

mask :: HasCallStack => ((forall a. IOEnv env a -> IOEnv env a) -> IOEnv env b) -> IOEnv env b Source #

uninterruptibleMask :: HasCallStack => ((forall a. IOEnv env a -> IOEnv env a) -> IOEnv env b) -> IOEnv env b Source #

generalBracket :: HasCallStack => IOEnv env a -> (a -> ExitCase b -> IOEnv env c) -> (a -> IOEnv env b) -> IOEnv env (b, c) Source #

MonadThrow (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods throwM :: (HasCallStack, Exception e) => e -> IOEnv env a Source #
ContainsHooks env => HasHooks (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods getHooks :: IOEnv env Hooks Source #
ContainsDynFlags env => HasDynFlags (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods getDynFlags :: IOEnv env DynFlags Source #
MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) Source # |
Instance details Defined in GHC.HsToCore.Monad Methods lookupThing :: Name -> IOEnv (Env DsGblEnv DsLclEnv) TyThing Source # lookupId :: Name -> IOEnv (Env DsGblEnv DsLclEnv) Id Source # lookupDataCon :: Name -> IOEnv (Env DsGblEnv DsLclEnv) DataCon Source # lookupTyCon :: Name -> IOEnv (Env DsGblEnv DsLclEnv) TyCon Source #
MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) Source # |
Instance details Defined in GHC.Tc.Utils.Env Methods lookupThing :: Name -> IOEnv (Env TcGblEnv TcLclEnv) TyThing Source # lookupId :: Name -> IOEnv (Env TcGblEnv TcLclEnv) Id Source # lookupDataCon :: Name -> IOEnv (Env TcGblEnv TcLclEnv) DataCon Source # lookupTyCon :: Name -> IOEnv (Env TcGblEnv TcLclEnv) TyCon Source #
MonadUnique (IOEnv (Env gbl lcl)) Source # |
Instance details Defined in GHC.Tc.Utils.Monad Methods getUniqueSupplyM :: IOEnv (Env gbl lcl) UniqSupply Source # getUniqueM :: IOEnv (Env gbl lcl) Unique Source # getUniquesM :: IOEnv (Env gbl lcl) [Unique] Source #
ContainsModule env => HasModule (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods getModule :: IOEnv env Module Source #
ContainsLogger env => HasLogger (IOEnv env) Source # |
Instance details Defined in GHC.Data.IOEnv Methods getLogger :: IOEnv env Logger Source #

module GHC.Utils.Monad

failM :: IOEnv env a Source #

failWithM :: String -> IOEnv env a Source #

data IOEnvFailure Source #

Constructors

IOEnvFailure |

#### Instances

Instances details

Exception IOEnvFailure Source # |
Instance details Defined in GHC.Data.IOEnv Methods toException :: IOEnvFailure -> SomeException Source # fromException :: SomeException -> Maybe IOEnvFailure Source # displayException :: IOEnvFailure -> String Source #
Show IOEnvFailure Source # |
Instance details Defined in GHC.Data.IOEnv Methods showsPrec :: Int -> IOEnvFailure -> ShowS Source # show :: IOEnvFailure -> String Source # showList :: [IOEnvFailure] -> ShowS Source #

getEnv :: IOEnv env env Source #

setEnv :: env' -> IOEnv env' a -> IOEnv env a Source #

Perform a computation with a different environment

updEnv :: (env -> env') -> IOEnv env' a -> IOEnv env a Source #

Perform a computation with an altered environment

runIOEnv :: env -> IOEnv env a -> IO a Source #

unsafeInterleaveM :: IOEnv env a -> IOEnv env a Source #

uninterruptibleMaskM_ :: IOEnv env a -> IOEnv env a Source #

tryM :: IOEnv env r -> IOEnv env (Either IOEnvFailure r) Source #

tryAllM :: IOEnv env r -> IOEnv env (Either SomeException r) Source #

tryMostM :: IOEnv env r -> IOEnv env (Either SomeException r) Source #

fixM :: (a -> IOEnv env a) -> IOEnv env a Source #

data IORef a Source #

A mutable variable in the `IO` monad.

    >>> import Data.IORef
    >>> r <- newIORef 0
    >>> readIORef r
    0
    >>> writeIORef r 1
    >>> readIORef r
    1
    >>> atomicWriteIORef r 2
    >>> readIORef r
    2
    >>> modifyIORef' r (+ 1)
    >>> readIORef r
    3
    >>> atomicModifyIORef' r (\a -> (a + 1, ()))
    >>> readIORef r
    4

See also `STRef` and `MVar`.

#### Instances

Instances details

NFData1 IORef | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> IORef a -> () Source #
NFData (IORef a) | NOTE: Only strict in the reference and not the referenced value. Since: deepseq-1.4.2.0
Instance details Defined in Control.DeepSeq Methods rnf :: IORef a -> () Source #
Eq (IORef a) | Pointer equality. Since: base-4.0.0.0
Instance details Defined in GHC.IORef Methods (==) :: IORef a -> IORef a -> Bool # (/=) :: IORef a -> IORef a -> Bool #

newMutVar :: a -> IOEnv env (IORef a) Source #

readMutVar :: IORef a -> IOEnv env a Source #

writeMutVar :: IORef a -> a -> IOEnv env () Source #

updMutVar :: IORef a -> (a -> a) -> IOEnv env () Source #

updMutVarM :: IORef a -> (a -> IOEnv env a) -> IOEnv env () Source #

atomicUpdMutVar :: IORef a -> (a -> (a, b)) -> IOEnv env b Source #

Atomically update the reference. Does not force the evaluation of the new variable contents. For strict update, use `atomicUpdMutVar'`.

atomicUpdMutVar' :: IORef a -> (a -> (a, b)) -> IOEnv env b Source #

Strict variant of `atomicUpdMutVar`.