System.Plugin
Contents
Methods
Arguments
| :: (String, String) | A tuple (
|
| -> ([String], String) | A tuple (
Note, type check maybe failed if |
| -> IO (Maybe a) | If the specified symbol is found, |
Polymorphic dynamic loading.
Resolves the specified symbol to any given type. This means linking the package containing it if it is not already linked, extracting the value of that symbol, and returning that value.
Here has simplest demo for test:
module Main where
import System.Plugin
import Unsafe.Coerce
main = do
val <- pdynload ("Prelude", "reverse") ([], "String -> String")
let str = case val of
Just v -> (unsafeCoerce v :: String -> String) "hello"
Nothing -> "Load failed."
print str
Because pdynload check type at runtime, so don't afraid unsafeCoerce,
it is perfect safety.