-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | dynamic plugin system for web applications -- -- dynamic plugin system for web applications @package web-plugins @version 0.2.2 module Web.Plugins.Core -- | When indicates when a clean up action should be run data When -- | always run this action when destroyPlugins is called Always :: When -- | only run this action if destroyPlugins is called with a failure -- present OnFailure :: When -- | only run this action when destroyPlugins is called with a -- normal shutdown OnNormal :: When -- | A Cleanup is an IO action to run when the server shuts -- down. The server can either shutdown normally or due to a failure. The -- When parameter indicates when an action should run. data Cleanup Cleanup :: When -> (IO ()) -> Cleanup -- | The PluginName should uniquely identify a plugin -- though we -- currently have no way to enforce that. type PluginName = Text -- | The PluginsState record holds all the record keeping -- information needed for loading, unloading, and invoking plugins. In -- theory you should not be modifying or inspecting this structure -- directly -- only calling the helper functions that modify or read it. data PluginsState theme n hook config st PluginsState :: Map PluginName (Plugins theme n hook config st -> [Text] -> n) -> [Cleanup] -> Map PluginName Dynamic -> Map PluginName (TVar Dynamic) -> Maybe theme -> [hook] -> config -> st -> PluginsState theme n hook config st pluginsHandler :: PluginsState theme n hook config st -> Map PluginName (Plugins theme n hook config st -> [Text] -> n) pluginsOnShutdown :: PluginsState theme n hook config st -> [Cleanup] pluginsRouteFn :: PluginsState theme n hook config st -> Map PluginName Dynamic -- | per-plugin state pluginsPluginState :: PluginsState theme n hook config st -> Map PluginName (TVar Dynamic) pluginsTheme :: PluginsState theme n hook config st -> Maybe theme pluginsPostHooks :: PluginsState theme n hook config st -> [hook] pluginsConfig :: PluginsState theme n hook config st -> config pluginsState :: PluginsState theme n hook config st -> st -- | The Plugins type is the handle to the plugins system. Generally -- you will have exactly one Plugins value in your app. -- -- see also withPlugins newtype Plugins theme m hook config st Plugins :: TVar (PluginsState theme m hook config st) -> Plugins theme m hook config st ptv :: Plugins theme m hook config st -> TVar (PluginsState theme m hook config st) -- | initialize the plugins system -- -- see also withPlugins initPlugins :: config -> st -> IO (Plugins theme n hook config st) -- | shutdown the plugins system -- -- see also withPlugins destroyPlugins :: When -> Plugins theme m hook config st -> IO () -- | a bracketed combination of initPlugins and -- destroyPlugins. Takes care of passing the correct termination -- condition. withPlugins :: config -> st -> (Plugins theme m hook config st -> IO a) -> IO a -- | get the current st value from Plugins getPluginsSt :: MonadIO m => Plugins theme n hook config st -> m st -- | put the current st value from Plugins putPluginsSt :: MonadIO m => Plugins theme n hook config st -> st -> m () -- | add a new plugin-local state addPluginState :: (MonadIO m, Typeable state) => Plugins theme n hook config st -> Text -> state -> m () -- | Get the state for a particular plugin -- -- per-plugin state is optional. This will return Nothing if the -- plugin did not register any local state. getPluginState :: (MonadIO m, Typeable state) => Plugins theme n hook config st -> Text -> m (Maybe state) -- | modify the current st value from Plugins modifyPluginsSt :: MonadIO m => Plugins theme n hook config st -> (st -> st) -> m () -- | add a new route handler addHandler :: MonadIO m => Plugins theme n hook config st -> Text -> (Plugins theme n hook config st -> [Text] -> n) -> m () -- | add a new cleanup action to the top of the stack addCleanup :: MonadIO m => Plugins theme n hook config st -> When -> IO () -> m () -- | add a new post initialization hook addPostHook :: MonadIO m => Plugins theme n hook config st -> hook -> m () -- | get all the post initialization hooks getPostHooks :: MonadIO m => Plugins theme n hook config st -> m [hook] -- | add the routing function for a plugin -- -- see also: getPluginRouteFn addPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> PluginName -> (url -> [(Text, Maybe Text)] -> Text) -> m () -- | get the plugin routing function for the named plugin -- -- see also: addPluginRouteFn getPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> PluginName -> m (Maybe (url -> [(Text, Maybe Text)] -> Text)) -- | set the current theme setTheme :: MonadIO m => Plugins theme n hook config st -> Maybe theme -> m () -- | get the current theme getTheme :: MonadIO m => Plugins theme n hook config st -> m (Maybe theme) -- | get the config value from the Plugins type getConfig :: MonadIO m => Plugins theme n hook config st -> m config -- | NOTE: it is possible to set the URL type incorrectly here and not get -- a type error. How can we fix that ? data Plugin url theme n hook config st Plugin :: PluginName -> (Plugins theme n hook config st -> IO (Maybe Text)) -> [PluginName] -> (url -> Text) -> hook -> Plugin url theme n hook config st pluginName :: Plugin url theme n hook config st -> PluginName pluginInit :: Plugin url theme n hook config st -> Plugins theme n hook config st -> IO (Maybe Text) -- | plugins which much be initialized before this one can be pluginDepends :: Plugin url theme n hook config st -> [PluginName] pluginToPathInfo :: Plugin url theme n hook config st -> url -> Text pluginPostHook :: Plugin url theme n hook config st -> hook -- | initialize a plugin initPlugin :: Typeable url => Plugins theme n hook config st -> PluginName -> Plugin url theme n hook config st -> IO (Maybe Text) -- | serve requests using the Plugins handle serve :: Plugins theme n hook config st -> PluginName -> [Text] -> IO (Either String n) instance Eq When instance Ord When instance Show When