dynamic-loader-0.0: lightweight loader of GHC-based modules or packages

Portabilitynon-portable (ghc >= 7.6 only)
Stabilityexperimental
Maintainerggreif+dynamic@gmail.com
Safe HaskellNone

System.Plugins.NameLoader

Description

A module that implements dynamic loading. Has smart handling of dependencies and is thread safe.

Synopsis

Documentation

setEnvironment :: Maybe FilePath -> Maybe String -> Maybe FilePath -> Maybe String -> Maybe String -> IO ()Source

Set the environment in wich all module loading will reside. If this function isn't called the defaults will be used.

The parameters are: Path to modules, module suffix, path to packages, package prefix and package suffix. The paths will default to current directory and the rest (in order) to o, HS and o.

addDependency :: Module -> Module -> IO ()Source

Add a module dependency. Any dependencies must be added before any calls to loadModule or symbols will not be resolved with a crash as result.

delDependency :: Module -> Module -> IO ()Source

Delete a module dependency.

delAllDeps :: Module -> IO ()Source

Delete all dependencies for a module.

withDependencies :: Loadable c t t' => Criterion c t -> Module -> (Maybe [Module] -> 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 :: Module -> IO LoadedModuleSource

Load a module (or package) and modules 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.

It treats names begining with uppercase letters (such as Foo.Bar) as modules and other names (such as base) as packages.

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).

moduleLoadedAt :: LoadedModule -> IO UTCTimeSource

Give the modification time for a loded module. Will throw an exception if the module isn't loaded.

sm_path :: NameModule -> FilePathSource

addDLL :: String -> IO ()Source

Dynamically load a shared library (DLL or .so). A shared library can't be unloaded using this interface, if you need it use System.Posix.DynamicLinker instead.