Copyright | (c) Hampus Ram 2004 Gabor Greif 2012 |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | ggreif+dynamic@gmail.com |
Stability | experimental |
Portability | non-portable (ghc >= 7.6 only) |
Safe Haskell | None |
Language | Haskell98 |
A module that implements dynamic loading. Has smart handling of dependencies and is thread safe.
- type Module = String
- data LoadedModule
- data ModuleType
- setEnvironment :: Maybe FilePath -> Maybe String -> Maybe FilePath -> Maybe String -> Maybe String -> IO ()
- addDependency :: Module -> Module -> IO ()
- delDependency :: Module -> Module -> IO ()
- delAllDeps :: Module -> IO ()
- withDependencies :: Loadable c t t' => Criterion c t -> Module -> (Maybe [Module] -> Effective c t) -> Effective c t
- loadModule :: Module -> IO LoadedModule
- unloadModule :: LoadedModule -> IO ()
- unloadModuleQuiet :: LoadedModule -> IO ()
- loadFunction :: Loadable c t t' => Criterion c t -> LoadedModule -> String -> Effective c t
- moduleLoadedAt :: LoadedModule -> IO UTCTime
- loadedModules :: IO [String]
- sm_path :: NameModule -> FilePath
- addDLL :: String -> IO ()
Documentation
data LoadedModule Source #
data ModuleType Source #
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.
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 t Source #
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 LoadedModule Source #
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 t Source #
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 UTCTime Source #
Give the modification time for a loded module. Will throw an exception if the module isn't loaded.
loadedModules :: IO [String] Source #