我通过设置一个阴谋集团沙箱并运行安装了threepenny-gui
cabal install threepenny-gui -fbuildExamples
这似乎工作正常。这些示例在.cabal-sandbox/bin
-folder 中找到,并且它们运行良好。
之后我查看了示例的源代码并尝试使用runhaskell
and ghci
-scripts 运行它们并得到以下错误
>./runhaskell CRUD.hs
../src/Foreign/JavaScript/Marshal.hs:62:7: Warning:
In the use of ‘Data.Aeson.Encode.fromValue’
(imported from Data.Aeson.Encode):
Deprecated: "Use 'encodeToTextBuilder' instead"
../src/Graphics/UI/Threepenny/Core.hs:349:43:
Could not deduce (JS.FromJS a) arising from a use of ‘get’
from the context (ToJS a, FFI (JSFunction a))
bound by the type signature for
fromObjectProperty :: (ToJS a, FFI (JSFunction a)) =>
String -> Attr Element a
at ../src/Graphics/UI/Threepenny/Core.hs:348:23-78
Possible fix:
add (JS.FromJS a) to the context of
the type signature for
fromObjectProperty :: (ToJS a, FFI (JSFunction a)) =>
String -> Attr Element a
In the first argument of ‘mkReadWriteAttr’, namely ‘get’
In the expression: mkReadWriteAttr get set
In an equation for ‘fromObjectProperty’:
fromObjectProperty name
= mkReadWriteAttr get set
where
set v el = runFunction $ ffi ("%1." ++ name ++ " = %2") el v
get el = callFunction $ ffi ("%1." ++ name) el
与这两个脚本。我还尝试从http://hackage.haskell.org/package/threepenny-gui-0.6.0.1/docs/Graphics-UI-Threepenny.html运行/编译示例程序,导致以下错误
> ghci test.hs
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
test.hs:3:18:
Could not find module ‘Graphics.UI.Threepenny’
Use -v to see a list of the files searched for.
test.hs:4:25:
Could not find module ‘Graphics.UI.Threepenny.Core’
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
我在 Haskell 中使用外部库的经验非常有限,而后者显然来自 ghc 不知道在哪里寻找这些包。
如何为 ghc 提供正确的路径并Core.hs
使其正常工作?