我希望使用hint
嵌入一个Haskell解释器,这样我就可以用Haskell编写插件来与我的程序一起使用。我不想为我的可执行文件提供整个Haskell平台。
通常,Haskell可执行文件是非常独立的。例如,擦除PATH
不会导致问题:
$ PATH=. Hello
Hello world
然而,一个简单的测试程序使用runInterpreter
炸弹,如果我擦除PATH
$ PATH=. TryHint
GhcException "panic! (the 'impossible' happened)\n (GHC version 7.8.3 for x86_64-apple-darwin):\n\tDynamic linker not initialised\n\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n"
环境中必须提供哪些库或可执行文件才能使其工作?
otool
没有给出太多的指导:
otool -L TryHint
TryHint:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/lib/libgmp.10.dylib (compatibility version 13.0.0, current version 13.0.0)
TryHint
的测试代码并没有做太多的事情:
import Control.Monad
import Language.Haskell.Interpreter
main = do
f <- runInterpreter $ loadModules ["Test"] >> setTopLevelModules ["Test"] >> interpret "f" (as :: Int -> Int)
case f of
Left e -> print e
Right r -> mapM_ (print . r) [1..10]
它只是将f
绑定到Test.hs
中的一个函数,以便在运行时进行解释。Test.hs
看起来像这样:
module Test where
f :: Int -> Int
f x = x + 1
https://stackoverflow.com/questions/28204973
复制相似问题