[英]Running code with threepenny-gui
我通过设置Cabal沙箱并运行来安装threepenny-gui
cabal install threepenny-gui -fbuildExamples
这似乎工作正常。 这些示例可在.cabal-sandbox/bin
夹中找到,并且可以.cabal-sandbox/bin
工作。
之后,我查看了示例的源代码,并尝试使用runhaskell
和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
正常工作?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.