happstack-plugins-7.0.1: The haskell application server stack + reload

Safe HaskellNone

Happstack.Server.Plugins.Dynamic

Synopsis

Documentation

data PluginHandle

A handle holding the reloader state.

data PluginConf

Configuration options for recompiling plugins. So far we store here event callbacks and ghc arguments.

Constructors

PluginConf 

Fields

pcGHCArgs :: [String]

Arguments to ghc

pcWhenCompiling :: FilePath -> IO ()

Called when compilation is about to start. Takes the path of the file to compile.

pcWhenCompiled :: FilePath -> [String] -> IO ()

Called after compilation finished. Takes the path of the compiled file and the compilation errors if any.

pcWhenReloaded :: FilePath -> String -> [String] -> IO ()

Called after reloading of the symbol finished. Takes the path of the object file, the symbol name and the list of errors if any.

pcWhenWatched :: FilePath -> IO ()

Called when a file is registered for watching.

pcWhenChanged :: FilePath -> IO ()

Called when a watched file is modified.

initPlugins :: IO PluginHandle

Initializes the plugin system and return a PluginHandle using the default plugin configuration defaultPluginConf.

initPluginsWithConf :: PluginConf -> IO PluginHandle

Initializes the plugin system and return a PluginHandle.

defaultPluginConf :: PluginConf

Contains no arguments for GHC, and noop callbacks.

withServerPart :: Name -> ExpQSource

dynamically load the specified symbol pass it as an argument to the supplied server monad function.

This is a wrapper aronud withServerPart_ which ensures the first and second argument stay in-sync.

Usage:

 $(withServerPart 'symbol) pluginHandle id $ \errors a -> ...

withServerPart_Source

Arguments

:: (MonadIO m, ServerMonad m, FilterMonad Response m, WebMonad Response m) 
=> Name

name of the symbol to dynamically load

-> a

the symbol (must be the function refered to by the Name argument)

-> PluginHandle

Handle to the function reloader

-> ([String] -> a -> m b)

function which uses the loaded result, and gets a list of compilation errors if any

-> m b 

dynamically load the specified symbol pass it as an argument to the supplied server monad function.

If something fails, this function will return '500 Internal Server Error' and a list of the errors encountered.

see also: withServerPart