Hoogle Search
Within LTS Haskell 24.67 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
effectful-core Effectful.Dispatch.Dynamic Lend effects to the local environment. Consider the following effect:
>>> :{ data D :: Effect where D :: D m () type instance DispatchOf D = Dynamic :}and an auxiliary effect that requires both IOE and D to run:>>> :{ data E :: Effect runE :: (IOE :> es, D :> es) => Eff (E : es) a -> Eff es a runE = error "runE" :}Trying to use runE inside the handler of D doesn't work out of the box:>>> :{ runD :: IOE :> es => Eff (D : es) a -> Eff es a runD = interpret $ \env -> \case D -> localSeqUnlift env $ \unlift -> do unlift . runE $ pure () :} ... ...Could not deduce ...IOE :> localEs... arising from a use of ‘runE’ ...from the context: IOE :> es ...The problem is that runE needs IOE :> localEs, but only IOE :> es is available. This function allows us to bridge the gap:>>> :{ runD :: IOE :> es => Eff (D : es) a -> Eff es a runD = interpret $ \env -> \case D -> localSeqUnlift env $ \unlift -> do localSeqLend @'[IOE] env $ \useIOE -> do unlift . useIOE . runE $ pure () :} -
effectful-core Effectful.Dispatch.Dynamic Create a local lifting function with the SeqUnlift strategy. For the general version see localLift.
-
effectful-core Effectful.Dispatch.Dynamic Create a local unlifting function with the SeqUnlift strategy. For the general version see localUnlift.
-
effectful-core Effectful.Dispatch.Dynamic Create a local unlifting function with the SeqUnlift strategy. For the general version see localUnliftIO.
-
effectful-core Effectful.Dispatch.Static Create an unlifting function with the SeqUnlift strategy.
-
effectful-core Effectful.Dispatch.Static Create an unlifting function with the SeqUnlift strategy. This function is unsafe because it can be used to introduce arbitrary IO actions into pure Eff computations.
SeqForkUnlift :: UnliftStrategyeffectful-core Effectful.Internal.Monad Like SeqUnlift, but all unlifted actions will be executed in a cloned environment. The main consequence is that thread local state is forked at the point of creation of the unlifting function and its modifications in unlifted actions will not affect the main thread of execution (and vice versa):
>>> import Effectful >>> import Effectful.State.Dynamic >>> :{ action :: (IOE :> es, State Int :> es) => Eff es () action = do modify @Int (+1) withEffToIO SeqForkUnlift $ \unlift -> unlift $ modify @Int (+2) modify @Int (+4) :}>>> runEff . execStateLocal @Int 0 $ action 5
>>> runEff . execStateShared @Int 0 $ action 7
Because of this it's possible to safely use the unlifting function outside of the scope of effects it captures, e.g. by creating an IO action that executes effectful operations and running it later:>>> :{ delayed :: UnliftStrategy -> IO (IO String) delayed strategy = runEff . evalStateLocal "Hey" $ do r <- withEffToIO strategy $ \unlift -> pure $ unlift get modify (++ "!!!") pure r :}This doesn't work with the SeqUnlift strategy because when the returned action runs, State is no longer in scope:>>> join $ delayed SeqUnlift *** Exception: version (...) /= storageVersion (0) ...
However, it does with the SeqForkUnlift strategy:>>> join $ delayed SeqForkUnlift "Hey"
-
effectful-core Effectful.Internal.Monad The sequential strategy is the fastest and a default setting for IOE. Any attempt of calling the unlifting function in threads distinct from its creator will result in a runtime error.
-
effectful-core Effectful.Internal.Monad Create an unlifting function with the SeqForkUnlift strategy.
-
effectful-core Effectful.Internal.Monad Create an unlifting function with the SeqUnlift strategy.