packages feed

pdynload 0.0.2 → 0.0.3

raw patch · 3 files changed

+22/−18 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- System.Plugin: pdynload :: (String, String) -> (String, String) -> IO (Maybe a)
+ System.Plugin: pdynload :: (String, String) -> ([String], String) -> IO (Maybe a)

Files

Demo/Main.hs view
@@ -4,7 +4,7 @@ import Unsafe.Coerce  main = do-  val <- pdynload ("Prelude", "reverse") ("", "String -> String")+  val <- pdynload ("Prelude", "reverse") ([], "String -> String")   let str = case val of               Just v  -> (unsafeCoerce v :: String -> String) "hello"               Nothing -> "Load failed."
System/Plugin.hs view
@@ -54,7 +54,7 @@ -- > import Unsafe.Coerce -- >  -- > main = do--- >   val <- pdynload ("Prelude", "reverse") ("", "String -> String")+-- >   val <- pdynload ("Prelude", "reverse") ([], "String -> String") -- >   let str = case val of -- >               Just v  -> (unsafeCoerce v :: String -> String) "hello" -- >               Nothing -> "Load failed."@@ -69,18 +69,20 @@          --   @symbolModule@ is a fully-qualified module name, ie @\"Data.List\"@          --             --   @symbol@ is an unqualified symbol name, ie @\"reverse\"@.-         -> (String, String) -         -- ^ A tuple (@typModule@, @typ@), specifying a type in module+         -> ([String], String) +         -- ^ A tuple (@typModuleList@, @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'.+         --   @typModuleList@ is list module name, ie @[\"Prelude\"]@ ,+         --   you can empty this list if type define in 'Prelude'.          --             --   @typ@ is an unqualified type name, ie @\"String -> String\"@.+         --+         -- Note, type check maybe failed if @typ@ can't found in module list @typModuleList@.          -> IO (Maybe a)          -- ^ If the specified symbol is found, 'Just' its value. Otherwise, 'Nothing'.-pdynload (symbolModule, symbol) (typModule, typ) = do+pdynload (symbolModule, symbol) (typModuleList, typ) = do   putStr "* Check type ... "-  status <- typeCheck (symbolModule, symbol) (typModule, typ)+  status <- typeCheck (symbolModule, symbol) (typModuleList, typ)   case status of     TypeMismatch error -> do       putStrLn "failed : "@@ -130,7 +132,7 @@ -- -- Example ----- > typecheck ("Data.List", "reverse") ("Prelude", "String -> String")            +-- > typecheck ("Data.List", "reverse") ([], "String -> String")             -- -- will generate test module like below:             --@@ -150,16 +152,18 @@           --   @symbolModule@ is a fully-qualified module name, ie @\"Data.List\"@           --              --   @symbol@ is an unqualified symbol name, ie @\"reverse\"@.-          -> (String, String) -          -- ^ A tuple (@typModule@, @typ@), specifying a type in module+          -> ([String], String) +          -- ^ A tuple (@typModuleList@, @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.+          --   @typModuleList@ is list module name, ie @[\"Prelude\"]@ ,+          --   you can empty this list if type define in Prelude.           --              --   @typ@ is an unqualified type name, ie @\"String -> String\"@.+          --+          -- Note, type check maybe failed if @typ@ can't found in module list @typModuleList@.           -> IO TypeCheckStatus           -- ^ If type match return 'TypeMatch', otherwise return 'TypeMismatch' with error.-typeCheck (symbolModule, symbol) (typModule, typ) = do +typeCheck (symbolModule, symbol) (typModuleList, typ) = do    -- Get unique id.   uniqueId <- getPicoseconds  @@ -180,9 +184,9 @@                       -- Import symbol module qualified.                       ++ "import qualified " ++ symbolModule ++ "\n"                       -- Import type module qualified.-                      ++ (if null typModule -                          then "import Prelude\n"-                          else "import " ++ typModule ++ "\n")+                      ++ (if null typModuleList +                          then "import Prelude\n" -- import Prelude if module list is empty+                          else concatMap (\mod -> "import " ++ mod ++ "\n") typModuleList)                       -- typecheck = SymbolModule.symbol :: TypeModule.Type                       ++ checkExpression ++ " = " ++ (symbolModule ++ "." ++ symbol) -- symbol expression                       ++ " :: " ++ typ                                     -- type expression
pdynload.cabal view
@@ -1,5 +1,5 @@ name:			pdynload-version:		0.0.2+version:		0.0.3 Cabal-Version:	>= 1.6 license:		GPL-3 license-file:	LICENSE