1

我已经安装了:

  • fay-0.19.0.1
  • fay-base-0.19

我正在尝试编译

-- test.hs
module Main where

import FFI

main = ffi "alert('hello world');"

fay test.hs

并得到

fay: unable to resolve qualified names ffi

请注意,我可以使用 fay-jquery、fay-text 等进行编译。编译和运行的完整源文件(使用 fay-base)并在执行它们时执行我期望它们执行的操作。但是,一旦我尝试ffi在其中任何一个中使用,我就会收到此错误。

fay-jquery、fay-dom 和其他使用 ffi 的包在我导入它们时似乎表现良好。

我不知道还有什么要说的?我在运行 Ubuntu 的 ghc 7.6.3 上。

帮助将不胜感激:)

4

1 回答 1

3

导入 Prelude 并为使用 FFI 的任何内容添加类型签名。

module Console (main) where

import Prelude
import FFI

main :: Fay ()
main = putStrLn (showInt (fib 10))

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

showInt :: Int -> String
showInt = ffi "%1+''"

编译。

注释掉import Prelude返回错误:src/console.hs:7:8: Not in scope: putStrLn'等等。

注释掉showInt :: Int -> String返回错误:fay: your FFI declaration needs a type signature: showInt = ffi "%1+''"

解决这些问题,然后再试一试。

我们光荣的费伊苏维埃领导人告诉我,import Prelude如果您的劳工护照上有正确的印章,就不再需要了。

于 2014-01-25T18:40:15.830 回答