web-plugins-0.1.1: dynamic plugin system for web applications

Safe HaskellNone

Web.Plugins.Core

Contents

Synopsis

Documentation

data When Source

Constructors

Always 
OnFailure 
OnNormal 

Instances

data Cleanup Source

Constructors

Cleanup When (IO ()) 

data PluginsState theme n hook config st Source

Constructors

PluginsState 

Fields

pluginsHandler :: Map PluginName (Plugins theme n hook config st -> [Text] -> n)
 
pluginsOnShutdown :: [Cleanup]
 
pluginsRouteFn :: Map PluginName Dynamic
 
pluginsTheme :: Maybe theme
 
pluginsPostHooks :: [hook]
 
pluginsConfig :: config
 
pluginsState :: st
 

newtype Plugins theme m hook config st Source

we don't really want to give the Plugin unrestricted access to modify the PluginsState TVar. So we will use a newtype?

Constructors

Plugins 

Fields

ptv :: TVar (PluginsState theme m hook config st)
 

initPlugins :: config -> st -> IO (Plugins theme n hook config st)Source

destroyPlugins :: When -> Plugins theme m hook config st -> IO ()Source

withPlugins :: config -> st -> (Plugins theme m hook config st -> IO a) -> IO aSource

a bracketed combination of initPlugins and destroyPlugins. Takes care of passing the correct termination condition.

PluginsSt

getPluginsSt :: MonadIO m => Plugins theme n hook config st -> m stSource

putPluginsSt :: MonadIO m => Plugins theme n hook config st -> st -> m ()Source

modifyPluginsSt :: MonadIO m => Plugins theme n hook config st -> (st -> st) -> m ()Source

addHandler :: MonadIO m => Plugins theme n hook config st -> Text -> (Plugins theme n hook config st -> [Text] -> n) -> m ()Source

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

getPostHooks :: MonadIO m => Plugins theme n hook config st -> m [hook]Source

addPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> Text -> (url -> [(Text, Maybe Text)] -> Text) -> m ()Source

getPluginRouteFn :: (MonadIO m, Typeable url) => Plugins theme n hook config st -> Text -> m (Maybe (url -> [(Text, Maybe Text)] -> Text))Source

setTheme :: MonadIO m => Plugins theme n hook config st -> Maybe theme -> m ()Source

getTheme :: MonadIO m => Plugins theme n hook config st -> m (Maybe theme)Source

getConfig :: MonadIO m => Plugins theme n hook config st -> m configSource

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 ?

Constructors

Plugin 

Fields

pluginName :: PluginName
 
pluginInit :: Plugins theme n hook config st -> IO (Maybe Text)
 
pluginDepends :: [Text]

plugins which much be initialized before this one can be

pluginToPathInfo :: url -> Text
 
pluginPostHook :: hook
 

initPlugin :: Typeable url => Plugins theme n hook config st -> Text -> Plugin url theme n hook config st -> IO (Maybe Text)Source

serve :: Plugins theme n hook config st -> Text -> [Text] -> IO (Either String n)Source