ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

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
- updEnvIO :: (env -> IO 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 ()
- atomicUpdMutVar :: IORef a -> (a -> (a, b)) -> IOEnv env b
- atomicUpdMutVar' :: IORef a -> (a -> (a, b)) -> IOEnv env b

# Documentation

data IOEnv env a #

#### Instances

Instances details

MonadIO (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods liftIO :: IO a -> IOEnv env a #
MonadCatch (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods catch :: (HasCallStack, Exception e) => IOEnv env a -> (e -> IOEnv env a) -> IOEnv env a #
MonadMask (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods mask :: HasCallStack => ((forall a. IOEnv env a -> IOEnv env a) -> IOEnv env b) -> IOEnv env b # uninterruptibleMask :: HasCallStack => ((forall a. IOEnv env a -> IOEnv env a) -> IOEnv env b) -> IOEnv env b # generalBracket :: HasCallStack => IOEnv env a -> (a -> ExitCase b -> IOEnv env c) -> (a -> IOEnv env b) -> IOEnv env (b, c) #
MonadThrow (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods throwM :: (HasCallStack, Exception e) => e -> IOEnv env a #
Alternative (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods empty :: IOEnv env a # (<|>) :: IOEnv env a -> IOEnv env a -> IOEnv env a # some :: IOEnv env a -> IOEnv env [a] # many :: IOEnv env a -> IOEnv env [a] #
Applicative (IOEnv m) # |
Instance details Defined in GHC.Data.IOEnv Methods pure :: a -> IOEnv m a # (<*>) :: IOEnv m (a -> b) -> IOEnv m a -> IOEnv m b # liftA2 :: (a -> b -> c) -> IOEnv m a -> IOEnv m b -> IOEnv m c # (*>) :: IOEnv m a -> IOEnv m b -> IOEnv m b # (<*) :: IOEnv m a -> IOEnv m b -> IOEnv m a #
Functor (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods fmap :: (a -> b) -> IOEnv env a -> IOEnv env b # (<$) :: a -> IOEnv env b -> IOEnv env a #
Monad (IOEnv m) # |
Instance details Defined in GHC.Data.IOEnv Methods (>>=) :: IOEnv m a -> (a -> IOEnv m b) -> IOEnv m b # (>>) :: IOEnv m a -> IOEnv m b -> IOEnv m b # return :: a -> IOEnv m a #
MonadPlus (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods mzero :: IOEnv env a # mplus :: IOEnv env a -> IOEnv env a -> IOEnv env a #
MonadFail (IOEnv m) # |
Instance details Defined in GHC.Data.IOEnv Methods fail :: String -> IOEnv m a #
MonadFix (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods mfix :: (a -> IOEnv env a) -> IOEnv env a #
ContainsDynFlags env => HasDynFlags (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods getDynFlags :: IOEnv env DynFlags #
ContainsHooks env => HasHooks (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods getHooks :: IOEnv env Hooks #
ContainsModule env => HasModule (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods getModule :: IOEnv env Module #
ContainsLogger env => HasLogger (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods getLogger :: IOEnv env Logger #

module GHC.Utils.Monad

failM :: IOEnv env a #

failWithM :: String -> IOEnv env a #

data IOEnvFailure #

Constructors

IOEnvFailure |

#### Instances

Instances details

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

getEnv :: IOEnv env env #

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

Perform a computation with a different environment

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

Perform a computation with an altered environment

updEnvIO :: (env -> IO env') -> IOEnv env' a -> IOEnv env a #

Perform a computation with an altered environment

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 #

A mutable variable in the `IO` monad.

    >>> import GHC.Internal.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 -> () #
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 -> () #
Eq (IORef a) | Pointer equality. @since base-4.0.0.0
Instance details Defined in GHC.Internal.IORef Methods (==) :: IORef a -> IORef a -> Bool # (/=) :: IORef a -> IORef a -> Bool #

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 () #

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

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 #

Strict variant of `atomicUpdMutVar`.