用threepenny-gui运行代码

时间:2015-05-09 03:28:39

标签: haskell threepenny-gui

我通过设置cabal沙箱并运行

来安装了threepenny-gui
cabal install threepenny-gui -fbuildExamples

似乎工作正常。这些示例位于.cabal-sandbox/bin - 文件夹中,它们运行良好。

之后我查看了示例的源代码,并尝试使用runhaskellghci -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正常工作?

0 个答案:

没有答案