úÎ2(1CThe status of type check. Polymorphic dynamic loading. QResolves the specified symbol to any given type. This means linking the package Q 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 C val <- pdynload ("Prelude", "reverse") ("", "String -> String")  let str = case val of G Just v -> (unsafeCoerce v :: String -> String) "hello" ) Nothing -> "Load failed."  print str Because  check type at runtime, so don' t afraid ,  it is perfect safety.  A tuple ( symbolModule, symbol!), specifying a symbol in module  symbolModule& is a fully-qualified module name, ie " Data.List" symbol# is an unqualified symbol name, ie "reverse".  A tuple ( typModule, typ), specifying a type in module  typModule& is a fully-qualified module name, ie "Prelude" , / you can empty this string if type define in Prelude. typ! is an unqualified type name, ie "String -> String". "If the specified symbol is found,  its value. Otherwise, . Type check at runtime. PInstead of using any form of user-land dynamic types for runtime type checking, J We simply invoke the regular type checker on the test module at runtime. S This approach has the advantage that it is entirely independent of any extensions M of type type system supported by the underlying implementation. e It does not require any extension, but it also does not inhibit the use of any features  of the type system. Example  P typecheck ("Data.List", "reverse") ("Prelude", "String -> String") 2will generate test module like below:  $ module TypeCheck where  ( import qualified Data.List  import Prelude  ? typecheck = Data.List.reverse :: String -> String  Then call "ghc -e typecheck TypeCheck.hs" for type-check. % If evaluate successful, then return , otherwise return  with error.  A tuple ( symbolModule, symbol!), specifying a symbol in module  symbolModule& is a fully-qualified module name, ie " Data.List" symbol# is an unqualified symbol name, ie "reverse".  A tuple ( typModule, typ), specifying a type in module  typModule& is a fully-qualified module name, ie "Prelude" , 8 you can empty this string if type define in Prelude. typ! is an unqualified type name, ie "String -> String". If type match return , otherwise return  with error. /Internal load function for pdynload. 'Lookup package name from ghc database. 0Parse symbol whether defined in current module. : If symbol is re-export other module, parse recursively, , until found the define location of symbol. Get PackageConfig id string.  Has prefix? &Find symbol in export list of module. 7 Return module name when found symbol in export list.  Otherwise return Nothing. /Get picoseconds for build unique haskell file.  Write file. Try remove file if file exist.       pdynload-0.0.2 System.PluginpdynloadTypeCheckStatus TypeMismatch TypeMatchbase Unsafe.Coerce unsafeCoerce Data.MaybeJustNothing typeCheckloadlookupPackageName parseSymbolpackageConfigIdString hasPrefixfindSymbolInExportListgetPicosecondshWrite tryRemoveFile