liftIO

base Control.Monad.IO.Class, conduit Conduit, unliftio-core Control.Monad.IO.Unlift, yesod-core Yesod.Core, protolude Protolude, cairo Graphics.Rendering.Cairo, scotty Web.Scotty Web.Scotty.Trans, streaming Streaming, base-prelude BasePrelude, shake Development.Shake, turtle Turtle Turtle.Shell, shelly Shelly Shelly.Lifted Shelly.Pipe, cgi Network.CGI, classy-prelude ClassyPrelude, distributed-process Control.Distributed.Process, hosc Sound.Osc, streamly Streamly.Data.Stream.MkType Streamly.Internal.Data.Stream.MkType, effectful-core Effectful, universum Universum.Monad.Reexport, managed Control.Monad.Managed Control.Monad.Managed.Safe, ihaskell IHaskell.Eval.Evaluate IHaskellPrelude, hslua-core HsLua.Core HsLua.Core.Types, massiv Data.Massiv.Core, beam-core Database.Beam, HaTeX Text.LaTeX.Base.Writer, foundation Foundation.Monad, ghc-lib-parser GHC.Core.Opt.Monad GHC.Data.Stream GHC.Driver.Monad GHC.Utils.Monad, xmonad XMonad, annotated-exception Control.Exception.Annotated.UnliftIO, ghc-internal GHC.Internal.Control.Monad.IO.Class, rebase Rebase.Prelude, core-program Core.System.Base, hackage-security Hackage.Security.Client.Verify, xmonad-contrib XMonad.Config.Prime, apecs Apecs, mtl-prelude MTLPrelude, nvim-hs Neovim, rhine FRP.Rhine, list-transformer List.Transformer, gi-cairo-render GI.Cairo.Render, BNFC BNFC.Backend.Base, breakpoint Debug.Breakpoint.GhcFacade, can-i-haz Control.Monad.Except.CoHas Control.Monad.Reader.Has, heftia Control.Monad.Hefty, mandrill Network.API.Mandrill, verset Verset, distribution-opensuse OpenSuse.Prelude, hledger-web Hledger.Web.Import, pandoc-plot Text.Pandoc.Filter.Plot.Internal, termonad Termonad.Prelude
Lift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).

Example

import Control.Monad.Trans.State -- from the "transformers" library

printState :: Show s => StateT s IO ()
printState = do
state <- get
liftIO $ print state
Had we omitted liftIO, we would have ended up with this error:
• Couldn't match type ‘IO’ with ‘StateT s IO’
Expected type: StateT s IO ()
Actual type: IO ()
The important part here is the mismatch between StateT s IO () and IO (). Luckily, we know of a function that takes an IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:
> evalStateT printState "hello"
"hello"

> evalStateT printState 3
3
Lifting of IO actions. Not exported, as we want to encapsulate IO.
Lift a computation from the IO monad.
Lift a computation from the IO monad.
Lift an IO action directly into GenProcess, liftIO = lift . Process.LiftIO.
Lift an IO action. Note that this can only happen with ConcIO.
Lift an IO operation into CoreM while consuming its SimplCount
A helper function for lifting IO a -> IO b functions into any MonadUnliftIO.

Example

liftedTry :: (Exception e, MonadUnliftIO m) => m a -> m (Either e a)
liftedTry m = liftIOOp Control.Exception.try m
Lift an IO operation with 1 argument into another monad
Lift an IO operation with 2 arguments into another monad
Lift an IO action into the Moment monad, but defer its execution until compilation time. This can be useful for recursive definitions using MonadFix.
Schedule an IO action to be run later.
liftIOOp is a particular application of peelIO that allows lifting control operations of type (a -> IO b) -> IO b (e.g. alloca, withMVar v) to MonadPeelIO m => (a -> m b) -> m b.
liftIOOp f g = do
k <- peelIO
join $ liftIO $ f (k . g)
liftIOOp_ is a particular application of peelIO that allows lifting control operations of type IO a -> IO a (e.g. block) to MonadPeelIO m => m a -> m a.
liftIOOp_ f m = do
k <- peelIO
join $ liftIO $ f (k m)