-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Boot application by using plugins. -- -- Boot application. @package boots @version 0 -- | This module wrap salak into a plugin. module Boots.Plugin.Salak -- | Environment providing a configuration parser. class HasSalak cxt askSourcePack :: HasSalak cxt => Lens' cxt SourcePack -- | Plugin used for parse properties. pluginSalak :: (MonadIO m, MonadCatch m) => String -> Plugin () m SourcePack -- | Core type class of salak, which provide function to parse properties. class Monad m => MonadSalak (m :: Type -> Type) -- | Monad has the ability to get a SourcePack instance. askSalak :: MonadSalak m => m SourcePack -- | Get reload action which used for reload profiles askReload :: MonadSalak m => m (IO ReloadResult) -- | Parse properties using FromProp. For example: -- --
--   a :: Bool              <- require "bool.key"
--   b :: Maybe Int         <- require "int.optional.key"
--   c :: Either String Int <- require "int.error.key"
--   d :: IO Int            <- require "int.reloadable.key"
--   
-- -- require supports parse IO values, which actually wrap a -- MVar variable and can be reseted by reloading configurations. -- Normal value will not be affected by reloading configurations. require :: (MonadSalak m, MonadThrow m, FromProp m a) => Text -> m a instance Boots.Plugin.Salak.HasSalak Salak.Internal.Source.SourcePack instance Boots.Plugin.Salak.HasSalak cxt => Salak.Internal.Prop.MonadSalak (Boots.Internal.Plugin.Plugin cxt m) instance (GHC.Base.Monad m, Boots.Plugin.Salak.HasSalak cxt) => Salak.Internal.Prop.MonadSalak (Boots.Internal.App.AppT cxt m) -- | This module wrap a logging function into a plugin. module Boots.Plugin.Logger -- | Environment providing a logging function. class HasLogger cxt askLogger :: HasLogger cxt => Lens' cxt LogFunc -- | Logger config. data LogConfig LogConfig :: Word16 -> Maybe FilePath -> Word32 -> Word16 -> IO LogLevel -> LogConfig -- | Logger buffer size. [bufferSize] :: LogConfig -> Word16 -- | Logger file path. [file] :: LogConfig -> Maybe FilePath -- | Max logger file size. [maxSize] :: LogConfig -> Word32 -- | Max number of logger files should be reserved. [rotateHistory] :: LogConfig -> Word16 -- | Log level to show. [level] :: LogConfig -> IO LogLevel data LogFunc -- | Add additional trace info into log. addTrace :: Text -> LogFunc -> LogFunc -- | Plugin providing a logging function. pluginLogger :: (MonadIO m, MonadCatch m, HasSalak cxt) => Text -> Plugin cxt m LogFunc -- | See logDebug logInfo :: (HasCallStack, MonadLogger m) => Text -> m () -- | Logs a message with the location provided by an implicit -- CallStack. logDebug :: (HasCallStack, MonadLogger m) => Text -> m () -- | See logDebug logWarn :: (HasCallStack, MonadLogger m) => Text -> m () -- | See logDebug logError :: (HasCallStack, MonadLogger m) => Text -> m () -- | See logDebug logOther :: (HasCallStack, MonadLogger m) => LogLevel -> Text -> m () instance Boots.Plugin.Logger.HasLogger Boots.Plugin.Logger.LogFunc instance (Control.Monad.IO.Class.MonadIO m, Boots.Plugin.Logger.HasLogger cxt) => Control.Monad.Logger.MonadLogger (Boots.Internal.Plugin.Plugin cxt m) instance (Control.Monad.IO.Class.MonadIO m, Boots.Plugin.Logger.HasLogger cxt) => Control.Monad.Logger.MonadLogger (Boots.Internal.App.AppT cxt m) instance Data.Default.Class.Default Boots.Plugin.Logger.LogConfig instance Control.Monad.IO.Class.MonadIO m => Salak.Internal.Prop.FromProp m Boots.Plugin.Logger.LogConfig instance GHC.Base.Monad m => Salak.Internal.Prop.FromProp m Control.Monad.Logger.LogLevel -- | This module defines simple application plugin. module Boots.Plugin.Simple -- | Simple plugin initialized both configurations pluginSalak and -- logger pluginLogger. data Simple Simple :: SourcePack -> LogFunc -> Simple [sourcePack] :: Simple -> SourcePack [logFunc] :: Simple -> LogFunc -- | Environment values with a configuration parser and logging function. class HasSimple cxt askSimple :: HasSimple cxt => Lens' cxt Simple -- | Simple plugin provides a configuration parser and logging function. pluginSimple :: (MonadCatch m, MonadIO m) => Text -> Plugin () m Simple instance Boots.Plugin.Simple.HasSimple Boots.Plugin.Simple.Simple instance Boots.Plugin.Logger.HasLogger Boots.Plugin.Simple.Simple instance Boots.Plugin.Salak.HasSalak Boots.Plugin.Simple.Simple -- | Boot plugins. module Boots.Plugin -- | Boot application by using plugins. -- --
--   >>> booting (pluginSimple "application") (logInfo "hello")
--   2019-07-27 19:35:30  INFO [application] Ghci1 - hello
--   
--   >>> booting (pluginSimple "application") (require "user" >>= logInfo)
--   2019-07-27 19:37:45  INFO [application] Ghci2 - daniel
--   
module Boots -- | Run application using a plugin. Context cxt can't escape from -- m. booting :: Plugin () m cxt -> AppT cxt m () -> m () -- | Application monad transformation. data AppT cxt m a -- | Run application monad transformation. runAppT :: cxt -> AppT cxt m a -> m a -- | Lift a computation from the IO monad. liftIO :: MonadIO m => IO a -> m a -- | Retrieves the monad environment. ask :: MonadReader r m => m r -- | Lift a computation from the argument monad to the constructed monad. lift :: (MonadTrans t, Monad m) => m a -> t m a -- | Throw an exception. Note that this throws when this action is run in -- the monad m, not when it is applied. It is a generalization -- of Control.Exception's throwIO. -- -- Should satisfy the law: -- --
--   throwM e >> f = throwM e
--   
throwM :: (MonadThrow m, Exception e) => e -> m a -- | Plugin generates component u with the context of component -- i running in monad m. data Plugin i m u -- | Run plugin in given context i. runPlugin :: i -> Plugin i m u -> (u -> m ()) -> m () -- | Promote a plugin into another. promote :: i -> Plugin i m u -> Plugin x m u -- | Convert a plugin into another. withPlugin :: (i -> j) -> Plugin j m u -> Plugin i m u -- | Apply a function to transform the result of a continuation-passing -- computation. mapPlugin :: (m () -> m ()) -> Plugin i m u -> Plugin i m u -- | Create bracket style plugin, used for manage resources, which need to -- open and close. -- -- A simple example: -- --
--   >>> res = bracketP (putStrLn "open") (const $ putStrLn "close")
--   
--   >>> runPlugin () res (const $ putStrLn "using")
--   open
--   using
--   close
--   
bracketP :: MonadCatch m => m u -> (u -> m ()) -> Plugin i m u