Safe Haskell | None |
---|---|
Language | Haskell2010 |
RIO is equivalent to ResourceT (WriterT Warmup IO)
It can be used to instantiate "modules as records of functions"
where each module can allocate resources and have a "warmup phase"
to preload data or asses if it is working properly
Synopsis
- newtype Stop = Stop InternalState
- runStop :: Stop -> IO ()
- newtype RIO a = RIO {}
- withRegistry :: forall a b ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> (Result -> a -> IO b) -> IO b
- runRegistryT :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> ResourceT IO (a, Warmup)
- executeRegistry :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> IO (a, Warmup, Stop)
- unsafeRun :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO a
- unsafeRunWithStop :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO (a, Stop)
- warmupWith :: Warmup -> RIO ()
- allocate :: IO a -> (a -> IO ()) -> RIO a
Documentation
This newtype creates a monad to sequence module creation actions, cumulating start/stop tasks found along the way
Instances
Monad RIO Source # | |
Functor RIO Source # | |
Applicative RIO Source # | |
MonadIO RIO Source # | |
Defined in Data.Registry.RIO | |
MonadThrow RIO Source # | |
Defined in Data.Registry.RIO | |
MonadResource RIO Source # | |
Defined in Data.Registry.RIO liftResourceT :: ResourceT IO a -> RIO a # | |
MonadBase IO RIO Source # | |
Defined in Data.Registry.RIO |
For production
withRegistry :: forall a b ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> (Result -> a -> IO b) -> IO b Source #
This function must be used to run services involving a top module It creates the top module and invokes all warmup functions
The passed function f
is used to decide whether to continue or
not depending on the Result
runRegistryT :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> ResourceT IO (a, Warmup) Source #
This can be used if you want to insert the component creation inside
another action managed with ResourceT
. Or if you want to call runResourceT
yourself later
For testing
executeRegistry :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> IO (a, Warmup, Stop) Source #
Instantiate the component but don't execute the warmup (it may take time) and keep the Stop value to clean resources later This function statically checks that the component can be instantiated
unsafeRun :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO a Source #
Instantiate the component but don't execute the warmup (it may take time) and lose a way to cleanu up resources | Almost no compilation time is spent on checking that component resolution is possible
unsafeRunWithStop :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO (a, Stop) Source #