Safe Haskell | None |
---|
- data When
- data Cleanup = Cleanup When (IO ())
- type PluginName = Text
- data PluginsState theme n hook config st = PluginsState {
- pluginsHandler :: Map PluginName (Plugins theme n hook config st -> [Text] -> n)
- pluginsOnShutdown :: [Cleanup]
- pluginsRouteFn :: Map PluginName Dynamic
- pluginsPluginState :: Map PluginName (TVar Dynamic)
- pluginsTheme :: Maybe theme
- pluginsPostHooks :: [hook]
- pluginsConfig :: config
- pluginsState :: st
- newtype Plugins theme m hook config st = Plugins {
- ptv :: TVar (PluginsState theme m hook config st)
- initPlugins :: config -> st -> IO (Plugins theme n hook config st)
- destroyPlugins :: When -> Plugins theme m hook config st -> IO ()
- withPlugins :: config -> st -> (Plugins theme m hook config st -> IO a) -> IO a
- getPluginsSt :: MonadIO m => Plugins theme n hook config st -> m st
- putPluginsSt :: MonadIO m => Plugins theme n hook config st -> st -> m ()
- addPluginState :: (MonadIO m, Typeable state) => Plugins theme n hook config st -> Text -> state -> m ()
- getPluginState :: (MonadIO m, Typeable state) => Plugins theme n hook config st -> Text -> m (Maybe state)
- modifyPluginsSt :: MonadIO m => Plugins theme n hook config st -> (st -> st) -> m ()
- addHandler :: MonadIO m => Plugins theme n hook config st -> Text -> (Plugins theme n hook config st -> [Text] -> n) -> m ()
- addCleanup :: MonadIO m => Plugins theme n hook config st -> When -> IO () -> m ()
- addPostHook :: MonadIO m => Plugins theme n hook config st -> hook -> m ()
- getPostHooks :: MonadIO m => Plugins theme n hook config st -> m [hook]
- addPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> PluginName -> (url -> [(Text, Maybe Text)] -> Text) -> m ()
- getPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> PluginName -> m (Maybe (url -> [(Text, Maybe Text)] -> Text))
- setTheme :: MonadIO m => Plugins theme n hook config st -> Maybe theme -> m ()
- getTheme :: MonadIO m => Plugins theme n hook config st -> m (Maybe theme)
- getConfig :: MonadIO m => Plugins theme n hook config st -> m config
- data Plugin url theme n hook config st = Plugin {
- pluginName :: PluginName
- pluginInit :: Plugins theme n hook config st -> IO (Maybe Text)
- pluginDepends :: [PluginName]
- pluginToPathInfo :: url -> Text
- pluginPostHook :: hook
- initPlugin :: Typeable url => Plugins theme n hook config st -> PluginName -> Plugin url theme n hook config st -> IO (Maybe Text)
- serve :: Plugins theme n hook config st -> PluginName -> [Text] -> IO (Either String n)
Documentation
When
indicates when a clean up action should be run
Always | always run this action when |
OnFailure | only run this action if |
OnNormal | only run this action when |
type PluginName = TextSource
The PluginName
should uniquely identify a plugin -- though we
currently have no way to enforce that.
data PluginsState theme n hook config st Source
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.
PluginsState | |
|
newtype Plugins theme m hook config st Source
The Plugins
type is the handle to the plugins system. Generally
you will have exactly one Plugins
value in your app.
see also withPlugins
Plugins | |
|
:: config | initial value for the |
-> st | initial value for the |
-> IO (Plugins theme n hook config st) |
initialize the plugins system
see also withPlugins
shutdown the plugins system
see also withPlugins
:: config | initial config value |
-> st | initial state value |
-> (Plugins theme m hook config st -> IO a) | |
-> IO a |
a bracketed combination of initPlugins
and destroyPlugins
. Takes care of passing the correct termination condition.
getPluginsSt :: MonadIO m => Plugins theme n hook config st -> m stSource
get the current st
value from Plugins
putPluginsSt :: MonadIO m => Plugins theme n hook config st -> st -> m ()Source
put the current st value from Plugins
addPluginState :: (MonadIO m, Typeable state) => Plugins theme n hook config st -> Text -> state -> m ()Source
add a new plugin-local state
getPluginState :: (MonadIO m, Typeable state) => Plugins theme n hook config st -> Text -> m (Maybe state)Source
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.
modifyPluginsSt :: MonadIO m => Plugins theme n hook config st -> (st -> st) -> m ()Source
modify the current st value from Plugins
:: MonadIO m | |
=> Plugins theme n hook config st | |
-> Text | prefix which this route handles |
-> (Plugins theme n hook config st -> [Text] -> n) | |
-> m () |
add a new route handler
addCleanup :: MonadIO m => Plugins theme n hook config st -> When -> IO () -> m ()Source
add a new cleanup action to the top of the stack
addPostHook :: MonadIO m => Plugins theme n hook config st -> hook -> m ()Source
add a new post initialization hook
getPostHooks :: MonadIO m => Plugins theme n hook config st -> m [hook]Source
get all the post initialization hooks
addPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> PluginName -> (url -> [(Text, Maybe Text)] -> Text) -> m ()Source
add the routing function for a plugin
see also: getPluginRouteFn
:: (MonadIO m, Typeable url) | |
=> Plugins theme n hook config st | |
-> PluginName | name of plugin |
-> m (Maybe (url -> [(Text, Maybe Text)] -> Text)) |
get the plugin routing function for the named plugin
see also: addPluginRouteFn
setTheme :: MonadIO m => Plugins theme n hook config st -> Maybe theme -> m ()Source
set the current theme
getTheme :: MonadIO m => Plugins theme n hook config st -> m (Maybe theme)Source
get the current theme
getConfig :: MonadIO m => Plugins theme n hook config st -> m configSource
get the config
value from the Plugins
type
data Plugin url theme n hook config st Source
NOTE: it is possible to set the URL type incorrectly here and not get a type error. How can we fix that ?
Plugin | |
|
initPlugin :: Typeable url => Plugins theme n hook config st -> PluginName -> Plugin url theme n hook config st -> IO (Maybe Text)Source
initialize a plugin