| Portability | non-portable (ghc >= 7.6 only) |
|---|---|
| Stability | experimental |
| Maintainer | ggreif+dynamic@gmail.com |
| Safe Haskell | None |
System.Plugins.PathLoader
Description
A module that implements dynamic loading. Has smart handling of dependencies and is thread safe.
- data LoadedModule
- data ModuleType
- = MT_Module
- | MT_Package
- setBasePath :: Maybe FilePath -> IO ()
- addDependency :: FilePath -> (ModuleType, FilePath) -> IO ()
- setDependencies :: FilePath -> [(ModuleType, FilePath)] -> IO ()
- delDependency :: FilePath -> (ModuleType, FilePath) -> IO ()
- delAllDeps :: FilePath -> IO ()
- withDependencies :: Loadable c t t' => Criterion c t -> FilePath -> (Maybe [(ModuleType, FilePath)] -> Effective c t) -> Effective c t
- loadModule :: FilePath -> ModuleType -> IO LoadedModule
- unloadModule :: LoadedModule -> IO ()
- unloadModuleQuiet :: LoadedModule -> IO ()
- loadFunction :: Loadable c t t' => Criterion c t -> LoadedModule -> String -> Effective c t
- loadQualifiedFunction :: Loadable c t t' => Criterion c t -> String -> Effective c t
- moduleLoadedAt :: LoadedModule -> IO UTCTime
- loadedModules :: IO [String]
- addDLL :: String -> IO ()
Documentation
data LoadedModule Source
setBasePath :: Maybe FilePath -> IO ()Source
Set the base path used in figuring out module names. If not set the default (i.e. currentDirectory) will be used.
addDependency :: FilePath -> (ModuleType, FilePath) -> IO ()Source
Add a module dependency. Any dependencies must be added before any calls to loadModule/loadPackage or symbols will not be resolved with a crash as result.
setDependencies :: FilePath -> [(ModuleType, FilePath)] -> IO ()Source
Set all dependencies. All previous dependencies are removed.
delDependency :: FilePath -> (ModuleType, FilePath) -> IO ()Source
Delete a module dependency.
delAllDeps :: FilePath -> IO ()Source
Delete all dependencies for a module. Same behaviour as
setDependencies path [].
withDependencies :: Loadable c t t' => Criterion c t -> FilePath -> (Maybe [(ModuleType, FilePath)] -> Effective c t) -> Effective c tSource
Do something with the current dependencies of a module. You can't use (blocking) functions from this module in the function given to withDependencies. If you do so, a deadlock will occur.
loadModule :: FilePath -> ModuleType -> IO LoadedModuleSource
Load a module (or package) and modules (or packages) it depends on. It
is possible to load a module many times without any error
occuring. However to unload a module one needs to call unloadModule
the same number of times.
Before loading any modules you should add wich dependencies it has with addDependency (and which dependencies the modules upon which it depends have).
If the module already has been loaded nothing will be done except updating the reference count. I.e. if dependencies have been updated they will be ignored until the module has been completely unloaded and loaded again.
If any error occurs an exception is thrown.
unloadModule :: LoadedModule -> IO ()Source
Unload a module and all modules it depends on. This unloading only occurs if the module isn't needed by any other libraries or hasn't been loaded more than once. An exception is thrown in case of error.
unloadModuleQuiet :: LoadedModule -> IO ()Source
Same as unloadModule just doesn't trow any exceptions on error.
loadFunction :: Loadable c t t' => Criterion c t -> LoadedModule -> String -> Effective c tSource
Load a function from a module. It cannot load functions from packages and will throw an exception if one tries to do so. Also throws if an error occurs.
It seems (but I'm unsure) like any functions loaded will continue to be valid even after the module it resides in is unloaded. It will also still be valid if a new version of that module is loaded (it will thus still call the old function).
loadQualifiedFunction :: Loadable c t t' => Criterion c t -> String -> Effective c tSource
Load a qualified function from a module or package. It will throw an exception if an error occurs. Same restriction as for DynamicLinker.loadQualifiedFunction applies here too.
moduleLoadedAt :: LoadedModule -> IO UTCTimeSource
Give the modification time for a loded module. Will throw an exception if the module isn't loaded.
loadedModules :: IO [String]Source