W. *_*vis 7 haskell dynamic-compilation dynamic-loading
我一直在玩插件包.我希望主机应用程序在沙盒环境中动态编译和加载Haskell源文件.编译工作正常.只要插件仅引用沙箱中可用的模块,加载就会失败.这是我为插件所获得的:
module Plugin (resource) where
import ServerAPI
import System.Plugins -- this module is only available in the sandbox
resource = Interface { action = timesTwo }
timesTwo :: Integer -> IO Integer
timesTwo n = return $ n * 2
Run Code Online (Sandbox Code Playgroud)
从宿主应用程序加载插件如下所示:
pkgConfDir = "/home/me/plugins/.cabal-sandbox/x86_64-osx-ghc-7.8.4-packages.conf.d
loadedOk <- pdynload "Plugin.o" ["."] [pkgConfDir] "ServerAPI.Interface" "resource"
Run Code Online (Sandbox Code Playgroud)
这就是我在沙盒中得到的:
> cabal sandbox hc-pkg list
…
/home/me/plugins/.cabal-sandbox/x86_64-osx-ghc-7.8.4-packages.conf.d
plugins-1.5.4.0
…
Run Code Online (Sandbox Code Playgroud)
这是我在运行主机应用程序时得到的:
Failed to load interface for ‘System.Plugins.Env’
no package matching ‘plugins-1.5.4.0’ was found
Run Code Online (Sandbox Code Playgroud)
如上所述,当我摆脱import System.Plugins
插件中的语句时,代码会加载.我错过了什么?
编辑:
cabal文件:
name: plugins
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file: LICENSE
author: W. Davis
maintainer: w.davis@spam.me.not
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
executable plugins
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.8, plugins >=1.5 && <1.6
-- hs-source-dirs:
default-language: Haskell2010
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
451 次 |
最近记录: |