Question

I have installed:

  • fay-0.19.0.1
  • fay-base-0.19

And I'm trying to compile

-- test.hs
module Main where

import FFI

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

with

fay test.hs

And getting

fay: unable to resolve qualified names ffi

Note that I am able to compile things with fay-jquery, fay-text, etc. Full source files that compile and run (with fay-base) and do what I expect them to do when executing them. But as soon as I try to use ffi in any of then, I get this error.

fay-jquery, fay-dom, and other packages that use ffi seem to behave well when I import them.

I'm not sure what else to mention? I'm on ghc 7.6.3, running Ubuntu.

Help would be appreciated :)

Was it helpful?

Solution

Import Prelude and add a type signature to anything using 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+''"

Compiles.

Commenting out import Prelude returns error: src/console.hs:7:8: Not in scope: putStrLn' among others.

Commenting out showInt :: Int -> String returns error: fay: your FFI declaration needs a type signature: showInt = ffi "%1+''"

Fix those issues and give it another whirl.

I am told by our glorious leaders of the Fay Soviet that import Prelude is no longer necessary if you have the right stamps on your labor passport.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top